11import { buildJoinCompletions , detectJoinContext , parseTableReferences } from '@dotaz/frontend-shared/lib/join-completion'
22import type { SchemaData } from '@dotaz/shared/types/database'
3+ import { DatabaseDataType } from '@dotaz/shared/types/database'
34import { describe , expect , it } from 'bun:test'
45
56// ── Helper ────────────────────────────────────────────────
@@ -9,29 +10,29 @@ function createSchemaData(overrides?: Partial<SchemaData>): SchemaData {
910 schemas : [ { name : 'public' } ] ,
1011 tables : {
1112 public : [
12- { name : 'orders' , type : 'table' } ,
13- { name : 'customers' , type : 'table' } ,
14- { name : 'products' , type : 'table' } ,
15- { name : 'order_items' , type : 'table' } ,
13+ { name : 'orders' , type : 'table' , schema : 'public' } ,
14+ { name : 'customers' , type : 'table' , schema : 'public' } ,
15+ { name : 'products' , type : 'table' , schema : 'public' } ,
16+ { name : 'order_items' , type : 'table' , schema : 'public' } ,
1617 ] ,
1718 } ,
1819 columns : {
1920 'public.orders' : [
20- { name : 'id' , dataType : 'integer' , nullable : false , isPrimaryKey : true } ,
21- { name : 'customer_id' , dataType : 'integer' , nullable : false , isPrimaryKey : false } ,
21+ { name : 'id' , dataType : DatabaseDataType . Integer , nullable : false , defaultValue : null , isPrimaryKey : true , isAutoIncrement : false } ,
22+ { name : 'customer_id' , dataType : DatabaseDataType . Integer , nullable : false , defaultValue : null , isPrimaryKey : false , isAutoIncrement : false } ,
2223 ] ,
2324 'public.customers' : [
24- { name : 'id' , dataType : 'integer' , nullable : false , isPrimaryKey : true } ,
25- { name : 'name' , dataType : 'text' , nullable : false , isPrimaryKey : false } ,
25+ { name : 'id' , dataType : DatabaseDataType . Integer , nullable : false , defaultValue : null , isPrimaryKey : true , isAutoIncrement : false } ,
26+ { name : 'name' , dataType : DatabaseDataType . Text , nullable : false , defaultValue : null , isPrimaryKey : false , isAutoIncrement : false } ,
2627 ] ,
2728 'public.order_items' : [
28- { name : 'id' , dataType : 'integer' , nullable : false , isPrimaryKey : true } ,
29- { name : 'order_id' , dataType : 'integer' , nullable : false , isPrimaryKey : false } ,
30- { name : 'product_id' , dataType : 'integer' , nullable : false , isPrimaryKey : false } ,
29+ { name : 'id' , dataType : DatabaseDataType . Integer , nullable : false , defaultValue : null , isPrimaryKey : true , isAutoIncrement : false } ,
30+ { name : 'order_id' , dataType : DatabaseDataType . Integer , nullable : false , defaultValue : null , isPrimaryKey : false , isAutoIncrement : false } ,
31+ { name : 'product_id' , dataType : DatabaseDataType . Integer , nullable : false , defaultValue : null , isPrimaryKey : false , isAutoIncrement : false } ,
3132 ] ,
3233 'public.products' : [
33- { name : 'id' , dataType : 'integer' , nullable : false , isPrimaryKey : true } ,
34- { name : 'name' , dataType : 'text' , nullable : false , isPrimaryKey : false } ,
34+ { name : 'id' , dataType : DatabaseDataType . Integer , nullable : false , defaultValue : null , isPrimaryKey : true , isAutoIncrement : false } ,
35+ { name : 'name' , dataType : DatabaseDataType . Text , nullable : false , defaultValue : null , isPrimaryKey : false , isAutoIncrement : false } ,
3536 ] ,
3637 } ,
3738 indexes : { } ,
@@ -283,7 +284,7 @@ describe('buildJoinCompletions', () => {
283284 it ( 'handles SQLite mode (no schema prefix)' , ( ) => {
284285 const sqliteSchema = createSchemaData ( )
285286 // For SQLite, use empty string as default schema but still key by "schema.table"
286- const completions = buildJoinCompletions (
287+ buildJoinCompletions (
287288 [ { table : 'orders' } ] ,
288289 sqliteSchema ,
289290 true ,
0 commit comments