File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -525,3 +525,20 @@ test('primary keys', async () => {
525
525
)
526
526
await pgMeta . tables . remove ( res . data ! . id )
527
527
} )
528
+
529
+ test ( 'composite primary keys preserve order' , async ( ) => {
530
+ let res = await pgMeta . tables . create ( { name : 't_pk_order' } )
531
+ await pgMeta . columns . create ( { table_id : res . data ! . id , name : 'col_a' , type : 'int8' } )
532
+ await pgMeta . columns . create ( { table_id : res . data ! . id , name : 'col_b' , type : 'text' } )
533
+ await pgMeta . columns . create ( { table_id : res . data ! . id , name : 'col_c' , type : 'int4' } )
534
+
535
+ // Set primary keys in specific order: col_c, col_a, col_b
536
+ res = await pgMeta . tables . update ( res . data ! . id , {
537
+ primary_keys : [ { name : 'col_c' } , { name : 'col_a' } , { name : 'col_b' } ] ,
538
+ } )
539
+
540
+ // Verify the order is preserved
541
+ expect ( res . data ! . primary_keys . map ( ( pk : any ) => pk . name ) ) . toEqual ( [ 'col_c' , 'col_a' , 'col_b' ] )
542
+
543
+ await pgMeta . tables . remove ( res . data ! . id )
544
+ } )
You can’t perform that action at this time.
0 commit comments