@@ -12,6 +12,10 @@ describe('SQL functions', () => {
1212 expect ( fn . json_extract ( JSON . stringify ( { foo : 42 } ) , '$' ) ) . toEqual ( '{"foo":42}' ) ;
1313 expect ( fn . json_extract ( `{"foo": 42.0}` , '$' ) ) . toEqual ( '{"foo":42.0}' ) ;
1414 expect ( fn . json_extract ( `{"foo": true}` , '$' ) ) . toEqual ( '{"foo":true}' ) ;
15+ // SQLite gives null instead of 'null'. We should match that, but it's a breaking change.
16+ expect ( fn . json_extract ( `{"foo": null}` , '$.foo' ) ) . toEqual ( 'null' ) ;
17+ // Matches SQLite
18+ expect ( fn . json_extract ( `{}` , '$.foo' ) ) . toBeNull ( ) ;
1519 } ) ;
1620
1721 test ( '->>' , ( ) => {
@@ -23,6 +27,10 @@ describe('SQL functions', () => {
2327 expect ( jsonExtract ( `{"foo": 42.0}` , 'foo' , '->>' ) ) . toEqual ( 42.0 ) ;
2428 expect ( jsonExtract ( `{"foo": 42.0}` , '$' , '->>' ) ) . toEqual ( `{"foo":42.0}` ) ;
2529 expect ( jsonExtract ( `{"foo": true}` , '$.foo' , '->>' ) ) . toEqual ( 1n ) ;
30+ // SQLite gives null instead of 'null'. We should match that, but it's a breaking change.
31+ expect ( jsonExtract ( `{"foo": null}` , '$.foo' , '->>' ) ) . toEqual ( 'null' ) ;
32+ // Matches SQLite
33+ expect ( jsonExtract ( `{}` , '$.foo' , '->>' ) ) . toBeNull ( ) ;
2634 } ) ;
2735
2836 test ( '->' , ( ) => {
@@ -34,6 +42,10 @@ describe('SQL functions', () => {
3442 expect ( jsonExtract ( `{"foo": 42.0}` , 'foo' , '->' ) ) . toEqual ( '42.0' ) ;
3543 expect ( jsonExtract ( `{"foo": 42.0}` , '$' , '->' ) ) . toEqual ( `{"foo":42.0}` ) ;
3644 expect ( jsonExtract ( `{"foo": true}` , '$.foo' , '->' ) ) . toEqual ( 'true' ) ;
45+ // SQLite gives 'null' instead of null. We should match that, but it's a breaking change.
46+ expect ( jsonExtract ( `{"foo": null}` , '$.foo' , '->' ) ) . toBeNull ( ) ;
47+ // Matches SQLite
48+ expect ( jsonExtract ( `{}` , '$.foo' , '->' ) ) . toBeNull ( ) ;
3749 } ) ;
3850
3951 test ( 'json_array_length' , ( ) => {
@@ -127,13 +139,13 @@ describe('SQL functions', () => {
127139 test ( 'iif' , ( ) => {
128140 expect ( fn . iif ( null , 1 , 2 ) ) . toEqual ( 2 ) ;
129141 expect ( fn . iif ( 0 , 1 , 2 ) ) . toEqual ( 2 ) ;
130- expect ( fn . iif ( 1 , " first" , " second" ) ) . toEqual ( " first" ) ;
131- expect ( fn . iif ( 0.1 , " is_true" , " is_false" ) ) . toEqual ( " is_true" ) ;
132- expect ( fn . iif ( "a" , " is_true" , " is_false" ) ) . toEqual ( " is_false" ) ;
133- expect ( fn . iif ( 0n , " is_true" , " is_false" ) ) . toEqual ( " is_false" ) ;
134- expect ( fn . iif ( 2n , " is_true" , " is_false" ) ) . toEqual ( " is_true" ) ;
135- expect ( fn . iif ( new Uint8Array ( [ ] ) , " is_true" , " is_false" ) ) . toEqual ( " is_false" ) ;
136- expect ( fn . iif ( Uint8Array . of ( 0x61 , 0x62 , 0x43 ) , " is_true" , " is_false" ) ) . toEqual ( " is_false" ) ;
142+ expect ( fn . iif ( 1 , ' first' , ' second' ) ) . toEqual ( ' first' ) ;
143+ expect ( fn . iif ( 0.1 , ' is_true' , ' is_false' ) ) . toEqual ( ' is_true' ) ;
144+ expect ( fn . iif ( 'a' , ' is_true' , ' is_false' ) ) . toEqual ( ' is_false' ) ;
145+ expect ( fn . iif ( 0n , ' is_true' , ' is_false' ) ) . toEqual ( ' is_false' ) ;
146+ expect ( fn . iif ( 2n , ' is_true' , ' is_false' ) ) . toEqual ( ' is_true' ) ;
147+ expect ( fn . iif ( new Uint8Array ( [ ] ) , ' is_true' , ' is_false' ) ) . toEqual ( ' is_false' ) ;
148+ expect ( fn . iif ( Uint8Array . of ( 0x61 , 0x62 , 0x43 ) , ' is_true' , ' is_false' ) ) . toEqual ( ' is_false' ) ;
137149 } ) ;
138150
139151 test ( 'upper' , ( ) => {
0 commit comments