From 02d078f2606b7f6013cea83b40f335e4ca2f076c Mon Sep 17 00:00:00 2001 From: Roland Teichert Date: Thu, 7 Nov 2024 14:34:55 +0200 Subject: [PATCH 1/2] Bugfix:Parse returned schema info as an object. Previously this was the default, but since a recent change to the mysql connection options, all JSON fields are now returned as strings. --- .../src/api/MySQLRouteAPIAdapter.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/modules/module-mysql/src/api/MySQLRouteAPIAdapter.ts b/modules/module-mysql/src/api/MySQLRouteAPIAdapter.ts index eb9c272af..dafcbf828 100644 --- a/modules/module-mysql/src/api/MySQLRouteAPIAdapter.ts +++ b/modules/module-mysql/src/api/MySQLRouteAPIAdapter.ts @@ -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 { @@ -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; From 04d61dca88fd075ecf356ddf7ab8d9aaca6bcaf9 Mon Sep 17 00:00:00 2001 From: Roland Teichert Date: Thu, 7 Nov 2024 14:49:04 +0200 Subject: [PATCH 2/2] Added changeset --- .changeset/healthy-rules-arrive.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/healthy-rules-arrive.md diff --git a/.changeset/healthy-rules-arrive.md b/.changeset/healthy-rules-arrive.md new file mode 100644 index 000000000..a64c34b1b --- /dev/null +++ b/.changeset/healthy-rules-arrive.md @@ -0,0 +1,5 @@ +--- +'@powersync/service-module-mysql': patch +--- + +Fixed mysql schema json parsing