@@ -46,6 +46,7 @@ describe('custom type registry', () => {
4646 } ) ;
4747
4848 test ( 'structure' , ( ) => {
49+ // create type c1 AS (a bool, b integer, c text[]);
4950 registry . set ( 1337 , {
5051 type : 'composite' ,
5152 sqliteType : ( ) => 'text' ,
@@ -56,10 +57,12 @@ describe('custom type registry', () => {
5657 ]
5758 } ) ;
5859
59- checkResult ( '(t,123,{foo,bar})' , 1337 , '(t,123,{foo,bar})' , '{"a":1,"b":123,"c":["foo","bar"]}' ) ;
60+ // SELECT (TRUE, 123, ARRAY['foo', 'bar'])::c1;
61+ checkResult ( '(t,123,"{foo,bar}")' , 1337 , '(t,123,"{foo,bar}")' , '{"a":1,"b":123,"c":["foo","bar"]}' ) ;
6062 } ) ;
6163
6264 test ( 'array of structure' , ( ) => {
65+ // create type c1 AS (a bool, b integer, c text[]);
6366 registry . set ( 1337 , {
6467 type : 'composite' ,
6568 sqliteType : ( ) => 'text' ,
@@ -71,11 +74,12 @@ describe('custom type registry', () => {
7174 } ) ;
7275 registry . set ( 1338 , { type : 'array' , separatorCharCode : CHAR_CODE_COMMA , innerId : 1337 , sqliteType : ( ) => 'text' } ) ;
7376
77+ // SELECT ARRAY[(TRUE, 123, ARRAY['foo', 'bar']),(FALSE, NULL, ARRAY[]::text[])]::c1[];
7478 checkResult (
75- '{(t,123,{foo,bar}), (f,0 ,{})}' ,
79+ '{" (t,123,\\" {foo,bar}\\")"," (f,,{})" }' ,
7680 1338 ,
77- '{(t,123,{foo,bar}), (f,0 ,{})}' ,
78- '[{"a":1,"b":123,"c":["foo","bar"]},{"a":0,"b":0 ,"c":[]}]'
81+ '{" (t,123,\\" {foo,bar}\\")"," (f,,{})" }' ,
82+ '[{"a":1,"b":123,"c":["foo","bar"]},{"a":0,"b":null ,"c":[]}]'
7983 ) ;
8084 } ) ;
8185
@@ -94,6 +98,7 @@ describe('custom type registry', () => {
9498 } ) ;
9599
96100 test ( 'structure of another structure' , ( ) => {
101+ // CREATE TYPE c2 AS (a BOOLEAN, b INTEGER);
97102 registry . set ( 1337 , {
98103 type : 'composite' ,
99104 sqliteType : ( ) => 'text' ,
@@ -103,12 +108,14 @@ describe('custom type registry', () => {
103108 ]
104109 } ) ;
105110 registry . set ( 1338 , { type : 'array' , separatorCharCode : CHAR_CODE_COMMA , innerId : 1337 , sqliteType : ( ) => 'text' } ) ;
111+ // CREATE TYPE c3 (c c2[]);
106112 registry . set ( 1339 , {
107113 type : 'composite' ,
108114 sqliteType : ( ) => 'text' ,
109115 members : [ { name : 'c' , typeId : 1338 } ]
110116 } ) ;
111117
112- checkResult ( '({(f,2)})' , 1339 , '({(f,2)})' , '{"c":[{"a":0,"b":2}]}' ) ;
118+ // SELECT ROW(ARRAY[(FALSE,2)]::c2[])::c3;
119+ checkResult ( '("{""(f,2)""}")' , 1339 , '("{""(f,2)""}")' , '{"c":[{"a":0,"b":2}]}' ) ;
113120 } ) ;
114121} ) ;
0 commit comments