@@ -11,63 +11,64 @@ describe('Test 042 - NULL values in INTO SQL()', function () {
1111 { a : null , b : 'value' , c : null , d : null } ,
1212 ] ;
1313 var res = alasql ( 'SELECT * INTO SQL({tableid:"test_table"}) FROM ?' , [ data ] ) ;
14-
14+
1515 console . log ( 'Generated SQL:' ) ;
1616 console . log ( res ) ;
17-
17+
1818 // Check that NULL appears in the output instead of empty values
1919 assert ( res . indexOf ( 'NULL' ) > - 1 , 'Output should contain NULL keyword' ) ;
20-
20+
2121 // Check that we don't have consecutive commas (,,) which indicate missing values
2222 assert ( res . indexOf ( ',,' ) === - 1 , 'Output should not contain consecutive commas (,,)' ) ;
23-
23+
2424 // Verify specific patterns for NULL values
2525 // First row: c should be NULL
26- assert ( res . indexOf ( ' (1,\ 'test\ ',NULL,3)' ) > - 1 , 'First row should have NULL for c' ) ;
27-
26+ assert ( res . indexOf ( " (1,'test',NULL,3)" ) > - 1 , 'First row should have NULL for c' ) ;
27+
2828 // Second row: b and d should be NULL
2929 assert ( res . indexOf ( '(2,NULL,4,NULL)' ) > - 1 , 'Second row should have NULL for b and d' ) ;
30-
30+
3131 // Third row: a, c, and d should be NULL
32- assert ( res . indexOf ( '(NULL,\'value\',NULL,NULL)' ) > - 1 , 'Third row should have NULL for a, c, and d' ) ;
33-
32+ assert (
33+ res . indexOf ( "(NULL,'value',NULL,NULL)" ) > - 1 ,
34+ 'Third row should have NULL for a, c, and d'
35+ ) ;
36+
3437 done ( ) ;
3538 } ) ;
36-
39+
3740 it ( '2. Should handle undefined values as NULL' , function ( done ) {
3841 var data = [
3942 { a : 1 , b : 'test' } ,
4043 { a : 2 , b : undefined , c : 4 } ,
4144 ] ;
4245 var res = alasql ( 'SELECT * INTO SQL({tableid:"test_table"}) FROM ?' , [ data ] ) ;
43-
46+
4447 console . log ( 'Generated SQL with undefined:' ) ;
4548 console . log ( res ) ;
46-
49+
4750 // Check that NULL appears in the output
4851 assert ( res . indexOf ( 'NULL' ) > - 1 , 'Output should contain NULL keyword for undefined values' ) ;
49-
52+
5053 // Check that we don't have consecutive commas
5154 assert ( res . indexOf ( ',,' ) === - 1 , 'Output should not contain consecutive commas (,,)' ) ;
52-
55+
5356 done ( ) ;
5457 } ) ;
55-
58+
5659 it ( '3. Should handle mixed NULL, undefined, and empty strings' , function ( done ) {
57- var data = [
58- { a : 1 , b : '' , c : null , d : undefined } ,
59- ] ;
60+ var data = [ { a : 1 , b : '' , c : null , d : undefined } ] ;
6061 var res = alasql ( 'SELECT * INTO SQL({tableid:"test_table"}) FROM ?' , [ data ] ) ;
61-
62+
6263 console . log ( 'Generated SQL with mixed values:' ) ;
6364 console . log ( res ) ;
64-
65+
6566 // Empty string should remain as empty string
66- assert ( res . indexOf ( "''" ) > - 1 , ' Empty string should be preserved as \'\'' ) ;
67-
67+ assert ( res . indexOf ( "''" ) > - 1 , " Empty string should be preserved as ''" ) ;
68+
6869 // null and undefined should become NULL
6970 assert ( res . indexOf ( 'NULL' ) > - 1 , 'null and undefined should become NULL' ) ;
70-
71+
7172 done ( ) ;
7273 } ) ;
7374} ) ;
0 commit comments