From ee77a7d0e62fe5c1f510df105e403273e66c6245 Mon Sep 17 00:00:00 2001 From: Mathieu Picciolli Date: Mon, 17 Aug 2026 14:34:10 -0400 Subject: [PATCH 1/2] chore(deps): bump cdb-converter to ^0.4.0 Update the lockfile and refresh the STA_race schema snapshots: the new converter reports the affected columns as INTEGER instead of NUMERIC and shifts a few column offsets. Co-Authored-By: Claude Opus 5 --- package-lock.json | 8 +- package.json | 2 +- .../get-table-schema.test.ts.snap | 86 +++++++++---------- 3 files changed, 48 insertions(+), 48 deletions(-) diff --git a/package-lock.json b/package-lock.json index 286caaa..1191bc2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@anthropic-ai/mcpb": "^2.1.2", "@modelcontextprotocol/sdk": "^1.29.0", - "cdb-converter": "^0.3.0", + "cdb-converter": "^0.4.0", "sql-query-identifier": "^3.1.1", "sql.js": "^1.14.1", "zod": "^4.4.3" @@ -2289,9 +2289,9 @@ } }, "node_modules/cdb-converter": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/cdb-converter/-/cdb-converter-0.3.0.tgz", - "integrity": "sha512-8Jst9m+sVdamZb9jKxXfL217bFKvVuggY9A/ZtVmROUBaWAnmRcZdxSi+bbXMUgOspbHs3Wm+9P09Irwszm3fA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/cdb-converter/-/cdb-converter-0.4.0.tgz", + "integrity": "sha512-8iz+vOYA1FTosWJ7MP7C1EhApNoCJlZArNCotKYH/hDu+GInxeeNYwKZn6+rjWjMvZJt+MKxLBsrAk5xPjEe7Q==", "license": "MIT", "dependencies": { "@types/sql.js": "^1.4.11", diff --git a/package.json b/package.json index c3c1902..2812924 100644 --- a/package.json +++ b/package.json @@ -50,7 +50,7 @@ "dependencies": { "@anthropic-ai/mcpb": "^2.1.2", "@modelcontextprotocol/sdk": "^1.29.0", - "cdb-converter": "^0.3.0", + "cdb-converter": "^0.4.0", "sql-query-identifier": "^3.1.1", "sql.js": "^1.14.1", "zod": "^4.4.3" diff --git a/test/tools/__snapshots__/get-table-schema.test.ts.snap b/test/tools/__snapshots__/get-table-schema.test.ts.snap index 00874be..5de60fc 100644 --- a/test/tools/__snapshots__/get-table-schema.test.ts.snap +++ b/test/tools/__snapshots__/get-table-schema.test.ts.snap @@ -8,7 +8,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "IDrace", "notNull": false, "primaryKey": false, - "type": "INTEGER 499717", + "type": "INTEGER 499712", }, { "name": "gene_sz_race_name", @@ -32,25 +32,25 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDcountry", "notNull": false, "primaryKey": false, - "type": "INTEGER 499797", + "type": "INTEGER 499792", }, { "name": "fkIDUCI_class", "notNull": false, "primaryKey": false, - "type": "INTEGER 499812", + "type": "INTEGER 499808", }, { "name": "fkIDfirst_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499845", + "type": "INTEGER 499840", }, { "name": "fkIDlast_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499861", + "type": "INTEGER 499856", }, { "name": "gene_f_popularity", @@ -62,7 +62,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499892", + "type": "INTEGER 499888", }, { "name": "gene_sz_mailOrganisateur", @@ -86,7 +86,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDLastRaceLeader", "notNull": false, "primaryKey": false, - "type": "INTEGER 499957", + "type": "INTEGER 499952", }, { "name": "CONSTANT", @@ -110,19 +110,19 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDtype_tour", "notNull": false, "primaryKey": false, - "type": "INTEGER 500036", + "type": "INTEGER 500032", }, { "name": "gene_b_ForceProtourInvitation", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500051", + "type": "INTEGER 500048", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500067", + "type": "INTEGER 500064", }, { "name": "gene_sz_currentvariant", @@ -140,7 +140,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500131", + "type": "INTEGER 500128", }, ], "name": "STA_race", @@ -156,7 +156,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "IDrace", "notNull": false, "primaryKey": false, - "type": "INTEGER 499717", + "type": "INTEGER 499712", }, { "name": "gene_sz_race_name", @@ -180,25 +180,25 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDcountry", "notNull": false, "primaryKey": false, - "type": "INTEGER 499797", + "type": "INTEGER 499792", }, { "name": "fkIDUCI_class", "notNull": false, "primaryKey": false, - "type": "INTEGER 499812", + "type": "INTEGER 499808", }, { "name": "fkIDfirst_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499845", + "type": "INTEGER 499840", }, { "name": "fkIDlast_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499861", + "type": "INTEGER 499856", }, { "name": "gene_f_popularity", @@ -210,7 +210,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499892", + "type": "INTEGER 499888", }, { "name": "gene_sz_mailOrganisateur", @@ -234,7 +234,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDLastRaceLeader", "notNull": false, "primaryKey": false, - "type": "INTEGER 499957", + "type": "INTEGER 499952", }, { "name": "CONSTANT", @@ -258,19 +258,19 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDtype_tour", "notNull": false, "primaryKey": false, - "type": "INTEGER 500036", + "type": "INTEGER 500032", }, { "name": "gene_b_ForceProtourInvitation", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500051", + "type": "INTEGER 500048", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500067", + "type": "INTEGER 500064", }, { "name": "gene_sz_currentvariant", @@ -288,7 +288,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500131", + "type": "INTEGER 500128", }, ], "name": "STA_race", @@ -304,7 +304,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "IDrace", "notNull": false, "primaryKey": false, - "type": "INTEGER 499717", + "type": "INTEGER 499712", }, { "name": "gene_sz_race_name", @@ -328,25 +328,25 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDcountry", "notNull": false, "primaryKey": false, - "type": "INTEGER 499797", + "type": "INTEGER 499792", }, { "name": "fkIDUCI_class", "notNull": false, "primaryKey": false, - "type": "INTEGER 499812", + "type": "INTEGER 499808", }, { "name": "fkIDfirst_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499845", + "type": "INTEGER 499840", }, { "name": "fkIDlast_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499861", + "type": "INTEGER 499856", }, { "name": "gene_f_popularity", @@ -358,7 +358,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499892", + "type": "INTEGER 499888", }, { "name": "gene_sz_mailOrganisateur", @@ -400,37 +400,37 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDrace_type", "notNull": false, "primaryKey": false, - "type": "INTEGER 500212", + "type": "INTEGER 500208", }, { "name": "gene_b_national_tour", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500147", + "type": "INTEGER 500144", }, { "name": "fkID_iconic_region", "notNull": false, "primaryKey": false, - "type": "INTEGER 500165", + "type": "INTEGER 500160", }, { "name": "gene_i_comfort", "notNull": false, "primaryKey": false, - "type": "INTEGER 500180", + "type": "INTEGER 500176", }, { "name": "gene_b_ForceProtourInvitation", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500051", + "type": "INTEGER 500048", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500067", + "type": "INTEGER 500064", }, { "name": "gene_sz_currentvariant", @@ -448,19 +448,19 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500131", + "type": "INTEGER 500128", }, { "name": "fkIDLastRaceLeader", "notNull": false, "primaryKey": false, - "type": "INTEGER 499957", + "type": "INTEGER 499952", }, { "name": "value_i_offsetLeapYear", "notNull": false, "primaryKey": false, - "type": "INTEGER 500196", + "type": "INTEGER 500192", }, ], "name": "STA_race", @@ -530,7 +530,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499892", + "type": "INTEGER 499888", }, { "name": "gene_sz_mailOrganisateur", @@ -578,7 +578,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_national_tour", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500147", + "type": "INTEGER 500144", }, { "name": "fkID_iconic_region", @@ -590,13 +590,13 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_comfort", "notNull": false, "primaryKey": false, - "type": "INTEGER 500180", + "type": "INTEGER 500176", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500067", + "type": "INTEGER 500064", }, { "name": "gene_sz_currentvariant", @@ -614,13 +614,13 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "NUMERIC 500131", + "type": "INTEGER 500128", }, { "name": "value_i_offsetLeapYear", "notNull": false, "primaryKey": false, - "type": "INTEGER 500196", + "type": "INTEGER 500192", }, ], "name": "STA_race", From cb7f87f1f7c597e3e4c4243879d14c10df611fd0 Mon Sep 17 00:00:00 2001 From: Mathieu Picciolli Date: Mon, 17 Aug 2026 14:37:17 -0400 Subject: [PATCH 2/2] feat(cdb): enable preciseTypes in cdbToSql conversion Update the get-table-schema snapshot accordingly. Co-Authored-By: Claude Opus 5 --- src/cdb.ts | 4 +- .../get-table-schema.test.ts.snap | 86 +++++++++---------- 2 files changed, 46 insertions(+), 44 deletions(-) diff --git a/src/cdb.ts b/src/cdb.ts index a640614..de90329 100644 --- a/src/cdb.ts +++ b/src/cdb.ts @@ -135,7 +135,9 @@ export async function withCdb>( const SQL = await initSqlJs(); const cdbBuffer = await readFile(file.path); - db = cdbToSql(cdbBuffer, SQL); + db = cdbToSql(cdbBuffer, SQL, { + preciseTypes: true, + }); if (config.queryOnly ?? true) { db.run("PRAGMA query_only = ON;"); diff --git a/test/tools/__snapshots__/get-table-schema.test.ts.snap b/test/tools/__snapshots__/get-table-schema.test.ts.snap index 5de60fc..00874be 100644 --- a/test/tools/__snapshots__/get-table-schema.test.ts.snap +++ b/test/tools/__snapshots__/get-table-schema.test.ts.snap @@ -8,7 +8,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "IDrace", "notNull": false, "primaryKey": false, - "type": "INTEGER 499712", + "type": "INTEGER 499717", }, { "name": "gene_sz_race_name", @@ -32,25 +32,25 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDcountry", "notNull": false, "primaryKey": false, - "type": "INTEGER 499792", + "type": "INTEGER 499797", }, { "name": "fkIDUCI_class", "notNull": false, "primaryKey": false, - "type": "INTEGER 499808", + "type": "INTEGER 499812", }, { "name": "fkIDfirst_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499840", + "type": "INTEGER 499845", }, { "name": "fkIDlast_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499856", + "type": "INTEGER 499861", }, { "name": "gene_f_popularity", @@ -62,7 +62,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499888", + "type": "INTEGER 499892", }, { "name": "gene_sz_mailOrganisateur", @@ -86,7 +86,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDLastRaceLeader", "notNull": false, "primaryKey": false, - "type": "INTEGER 499952", + "type": "INTEGER 499957", }, { "name": "CONSTANT", @@ -110,19 +110,19 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDtype_tour", "notNull": false, "primaryKey": false, - "type": "INTEGER 500032", + "type": "INTEGER 500036", }, { "name": "gene_b_ForceProtourInvitation", "notNull": false, "primaryKey": false, - "type": "INTEGER 500048", + "type": "NUMERIC 500051", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "INTEGER 500064", + "type": "NUMERIC 500067", }, { "name": "gene_sz_currentvariant", @@ -140,7 +140,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "INTEGER 500128", + "type": "NUMERIC 500131", }, ], "name": "STA_race", @@ -156,7 +156,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "IDrace", "notNull": false, "primaryKey": false, - "type": "INTEGER 499712", + "type": "INTEGER 499717", }, { "name": "gene_sz_race_name", @@ -180,25 +180,25 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDcountry", "notNull": false, "primaryKey": false, - "type": "INTEGER 499792", + "type": "INTEGER 499797", }, { "name": "fkIDUCI_class", "notNull": false, "primaryKey": false, - "type": "INTEGER 499808", + "type": "INTEGER 499812", }, { "name": "fkIDfirst_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499840", + "type": "INTEGER 499845", }, { "name": "fkIDlast_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499856", + "type": "INTEGER 499861", }, { "name": "gene_f_popularity", @@ -210,7 +210,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499888", + "type": "INTEGER 499892", }, { "name": "gene_sz_mailOrganisateur", @@ -234,7 +234,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDLastRaceLeader", "notNull": false, "primaryKey": false, - "type": "INTEGER 499952", + "type": "INTEGER 499957", }, { "name": "CONSTANT", @@ -258,19 +258,19 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDtype_tour", "notNull": false, "primaryKey": false, - "type": "INTEGER 500032", + "type": "INTEGER 500036", }, { "name": "gene_b_ForceProtourInvitation", "notNull": false, "primaryKey": false, - "type": "INTEGER 500048", + "type": "NUMERIC 500051", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "INTEGER 500064", + "type": "NUMERIC 500067", }, { "name": "gene_sz_currentvariant", @@ -288,7 +288,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "INTEGER 500128", + "type": "NUMERIC 500131", }, ], "name": "STA_race", @@ -304,7 +304,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "IDrace", "notNull": false, "primaryKey": false, - "type": "INTEGER 499712", + "type": "INTEGER 499717", }, { "name": "gene_sz_race_name", @@ -328,25 +328,25 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDcountry", "notNull": false, "primaryKey": false, - "type": "INTEGER 499792", + "type": "INTEGER 499797", }, { "name": "fkIDUCI_class", "notNull": false, "primaryKey": false, - "type": "INTEGER 499808", + "type": "INTEGER 499812", }, { "name": "fkIDfirst_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499840", + "type": "INTEGER 499845", }, { "name": "fkIDlast_stage", "notNull": false, "primaryKey": false, - "type": "INTEGER 499856", + "type": "INTEGER 499861", }, { "name": "gene_f_popularity", @@ -358,7 +358,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499888", + "type": "INTEGER 499892", }, { "name": "gene_sz_mailOrganisateur", @@ -400,37 +400,37 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "fkIDrace_type", "notNull": false, "primaryKey": false, - "type": "INTEGER 500208", + "type": "INTEGER 500212", }, { "name": "gene_b_national_tour", "notNull": false, "primaryKey": false, - "type": "INTEGER 500144", + "type": "NUMERIC 500147", }, { "name": "fkID_iconic_region", "notNull": false, "primaryKey": false, - "type": "INTEGER 500160", + "type": "INTEGER 500165", }, { "name": "gene_i_comfort", "notNull": false, "primaryKey": false, - "type": "INTEGER 500176", + "type": "INTEGER 500180", }, { "name": "gene_b_ForceProtourInvitation", "notNull": false, "primaryKey": false, - "type": "INTEGER 500048", + "type": "NUMERIC 500051", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "INTEGER 500064", + "type": "NUMERIC 500067", }, { "name": "gene_sz_currentvariant", @@ -448,19 +448,19 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "INTEGER 500128", + "type": "NUMERIC 500131", }, { "name": "fkIDLastRaceLeader", "notNull": false, "primaryKey": false, - "type": "INTEGER 499952", + "type": "INTEGER 499957", }, { "name": "value_i_offsetLeapYear", "notNull": false, "primaryKey": false, - "type": "INTEGER 500192", + "type": "INTEGER 500196", }, ], "name": "STA_race", @@ -530,7 +530,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_number_stages", "notNull": false, "primaryKey": false, - "type": "INTEGER 499888", + "type": "INTEGER 499892", }, { "name": "gene_sz_mailOrganisateur", @@ -578,7 +578,7 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_national_tour", "notNull": false, "primaryKey": false, - "type": "INTEGER 500144", + "type": "NUMERIC 500147", }, { "name": "fkID_iconic_region", @@ -590,13 +590,13 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_i_comfort", "notNull": false, "primaryKey": false, - "type": "INTEGER 500176", + "type": "INTEGER 500180", }, { "name": "gene_b_aso", "notNull": false, "primaryKey": false, - "type": "INTEGER 500064", + "type": "NUMERIC 500067", }, { "name": "gene_sz_currentvariant", @@ -614,13 +614,13 @@ exports[`getTableSchema > returns STA_race table schema for Pro cycling manager "name": "gene_b_selected", "notNull": false, "primaryKey": false, - "type": "INTEGER 500128", + "type": "NUMERIC 500131", }, { "name": "value_i_offsetLeapYear", "notNull": false, "primaryKey": false, - "type": "INTEGER 500192", + "type": "INTEGER 500196", }, ], "name": "STA_race",