Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/healthy-rules-arrive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@powersync/service-module-mysql': patch
---

Fixed mysql schema json parsing
18 changes: 10 additions & 8 deletions modules/module-mysql/src/api/MySQLRouteAPIAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { toExpressionTypeFromMySQLType } from '../common/common-index.js';
type SchemaResult = {
schema_name: string;
table_name: string;
columns: Array<{ data_type: string; column_name: string }>;
columns: string;
};

export class MySQLRouteAPIAdapter implements api.RouteAPI {
Expand Down Expand Up @@ -326,16 +326,18 @@ export class MySQLRouteAPIAdapter implements api.RouteAPI {
name: result.schema_name,
tables: []
});

const columns = JSON.parse(result.columns).map((column: { data_type: string; column_name: string }) => ({
name: column.column_name,
type: column.data_type,
sqlite_type: toExpressionTypeFromMySQLType(column.data_type).typeFlags,
internal_type: column.data_type,
pg_type: column.data_type
}));

schema.tables.push({
name: result.table_name,
columns: result.columns.map((column) => ({
name: column.column_name,
type: column.data_type,
sqlite_type: toExpressionTypeFromMySQLType(column.data_type).typeFlags,
internal_type: column.data_type,
pg_type: column.data_type
}))
columns: columns
});

return hash;
Expand Down
Loading