@@ -2142,7 +2142,7 @@ t('Does not try rollback when commit errors', async() => {
21422142} )
21432143
21442144t ( 'Last keyword used even with duplicate keywords' , async ( ) => {
2145- await sql `create table test (x int); `
2145+ await sql `create table test (x int)`
21462146 await sql `insert into test values(1)`
21472147 const [ { x } ] = await sql `
21482148 select
@@ -2151,5 +2151,35 @@ t('Last keyword used even with duplicate keywords', async() => {
21512151 where x in ${ sql ( [ 1 , 2 ] ) }
21522152 `
21532153
2154- return [ x , true ]
2154+ return [ x , true , await sql `drop table test` ]
2155+ } )
2156+
2157+ t ( 'Insert array with null' , async ( ) => {
2158+ await sql `create table test (x int[])`
2159+ await sql `insert into test ${ sql ( { x : [ 1 , null , 3 ] } ) } `
2160+ return [
2161+ 1 ,
2162+ ( await sql `select x from test` ) [ 0 ] . x [ 0 ] ,
2163+ await sql `drop table test`
2164+ ]
2165+ } )
2166+
2167+ t ( 'Insert array with undefined throws' , async ( ) => {
2168+ await sql `create table test (x int[])`
2169+ return [
2170+ 'UNDEFINED_VALUE' ,
2171+ await sql `insert into test ${ sql ( { x : [ 1 , undefined , 3 ] } ) } ` . catch ( e => e . code ) ,
2172+ await sql `drop table test`
2173+ ]
2174+ } )
2175+
2176+ t ( 'Insert array with undefined transform' , async ( ) => {
2177+ const sql = postgres ( { ...options , transform : { undefined : null } } )
2178+ await sql `create table test (x int[])`
2179+ await sql `insert into test ${ sql ( { x : [ 1 , undefined , 3 ] } ) } `
2180+ return [
2181+ 1 ,
2182+ ( await sql `select x from test` ) [ 0 ] . x [ 0 ] ,
2183+ await sql `drop table test`
2184+ ]
21552185} )
0 commit comments