@@ -220,6 +220,64 @@ it('interval type', async () => {
220220 expect ( sql ) . toMatchSnapshot ( ) ;
221221} ) ;
222222
223+ it ( 'null array fields emit empty array literal instead of NULL' , async ( ) => {
224+ const parser = new Parser ( {
225+ schema : 'metaschema_modules_public' ,
226+ singleStmts : true ,
227+ table : 'secure_table_provision' ,
228+ fields : {
229+ id : 'uuid' ,
230+ node_type : 'text' ,
231+ fields : 'jsonb[]' ,
232+ grant_privileges : 'jsonb[]' ,
233+ out_fields : 'uuid[]'
234+ }
235+ } ) ;
236+
237+ const sql = await parser . parse ( [
238+ {
239+ id : '450e3b3b-b68d-4abc-990c-65cb8a1dcdb4' ,
240+ node_type : 'DataTimestamps' ,
241+ fields : null ,
242+ grant_privileges : null ,
243+ out_fields : null
244+ }
245+ ] ) ;
246+
247+ // Should emit '{}' for array columns instead of NULL
248+ expect ( sql ) . toContain ( "'{}'" ) ;
249+ expect ( sql ) . not . toContain ( 'NULL' ) ;
250+ expect ( sql ) . toMatchSnapshot ( ) ;
251+ } ) ;
252+
253+ it ( 'empty array fields emit empty array literal' , async ( ) => {
254+ const parser = new Parser ( {
255+ schema : 'metaschema_modules_public' ,
256+ singleStmts : true ,
257+ table : 'secure_table_provision' ,
258+ fields : {
259+ id : 'uuid' ,
260+ node_type : 'text' ,
261+ fields : 'jsonb[]' ,
262+ grant_roles : 'text[]'
263+ }
264+ } ) ;
265+
266+ const sql = await parser . parse ( [
267+ {
268+ id : '450e3b3b-b68d-4abc-990c-65cb8a1dcdb4' ,
269+ node_type : 'DataTimestamps' ,
270+ fields : [ ] ,
271+ grant_roles : [ ]
272+ }
273+ ] ) ;
274+
275+ // Empty arrays should also emit '{}' not NULL
276+ expect ( sql ) . toContain ( "'{}'" ) ;
277+ expect ( sql ) . not . toContain ( 'NULL' ) ;
278+ expect ( sql ) . toMatchSnapshot ( ) ;
279+ } ) ;
280+
223281it ( 'interval type with string value' , async ( ) => {
224282 const parser = new Parser ( {
225283 schema : 'metaschema_modules_public' ,
0 commit comments