File tree Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Expand file tree Collapse file tree 2 files changed +50
-1
lines changed Original file line number Diff line number Diff line change 50
50
FROM
51
51
pg_catalog .pg_enum enums
52
52
WHERE
53
- quote_ident(COALESCE(bt .typname , t .typname )) = format_type(enums .enumtypid , NULL )
53
+ enums .enumtypid = coalesce(bt .oid , t .oid )
54
+ OR enums .enumtypid = coalesce(bt .typelem , t .typelem )
54
55
ORDER BY
55
56
enums .enumsortorder
56
57
)
Original file line number Diff line number Diff line change @@ -733,3 +733,51 @@ test('alter column to type with uppercase', async () => {
733
733
await pgMeta . tables . remove ( testTable ! . id )
734
734
await pgMeta . query ( 'DROP TYPE "T"' )
735
735
} )
736
+
737
+ test ( 'enums are populated in enum array columns' , async ( ) => {
738
+ await pgMeta . query ( `create type test_enum as enum ('a')` )
739
+ const { data : testTable } = await pgMeta . tables . create ( { name : 't' } )
740
+
741
+ let res = await pgMeta . columns . create ( {
742
+ table_id : testTable ! . id ,
743
+ name : 'c' ,
744
+ type : '_test_enum' ,
745
+ } )
746
+ expect ( res ) . toMatchInlineSnapshot (
747
+ {
748
+ data : {
749
+ id : expect . stringMatching ( / ^ \d + \. 1 $ / ) ,
750
+ table_id : expect . any ( Number ) ,
751
+ } ,
752
+ } ,
753
+ `
754
+ Object {
755
+ "data": Object {
756
+ "comment": null,
757
+ "data_type": "ARRAY",
758
+ "default_value": null,
759
+ "enums": Array [
760
+ "a",
761
+ ],
762
+ "format": "_test_enum",
763
+ "id": StringMatching /\\^\\\\d\\+\\\\\\.1\\$/,
764
+ "identity_generation": null,
765
+ "is_generated": false,
766
+ "is_identity": false,
767
+ "is_nullable": true,
768
+ "is_unique": false,
769
+ "is_updatable": true,
770
+ "name": "c",
771
+ "ordinal_position": 1,
772
+ "schema": "public",
773
+ "table": "t",
774
+ "table_id": Any<Number>,
775
+ },
776
+ "error": null,
777
+ }
778
+ `
779
+ )
780
+
781
+ await pgMeta . tables . remove ( testTable ! . id )
782
+ await pgMeta . query ( `drop type test_enum` )
783
+ } )
You can’t perform that action at this time.
0 commit comments