1+ import dedent from 'dedent-js' ;
12import { format as originalFormat , FormatFn } from '../src/sqlFormatter.js' ;
23import behavesLikeMariaDbFormatter from './behavesLikeMariaDbFormatter.js' ;
34
@@ -33,7 +34,7 @@ describe('SingleStoreDbFormatter', () => {
3334 ] ) ;
3435 supportsOperators (
3536 format ,
36- [ ':=' , '&' , '|' , '^' , '~' , '<<' , '>>' , '<=>' , '&&' , '||' ] ,
37+ [ ':=' , '&' , '|' , '^' , '~' , '<<' , '>>' , '<=>' , '&&' , '||' , ':>' , '!:>' ] ,
3738 [ 'AND' , 'OR' ]
3839 ) ;
3940 supportsLimiting ( format , { limit : true , offset : true } ) ;
@@ -45,4 +46,37 @@ describe('SingleStoreDbFormatter', () => {
4546 modify : true ,
4647 renameTo : true ,
4748 } ) ;
49+
50+ describe ( `formats traversal of semi structured data` , ( ) => {
51+ it ( `formats '::' path-operator without spaces` , ( ) => {
52+ expect ( format ( `SELECT * FROM foo WHERE json_foo::bar = 'foobar'` ) ) . toBe ( dedent `
53+ SELECT
54+ *
55+ FROM
56+ foo
57+ WHERE
58+ json_foo::bar = 'foobar'
59+ ` ) ;
60+ } ) ;
61+ it ( `formats '::$' conversion path-operator without spaces` , ( ) => {
62+ expect ( format ( `SELECT * FROM foo WHERE json_foo::$bar = 'foobar'` ) ) . toBe ( dedent `
63+ SELECT
64+ *
65+ FROM
66+ foo
67+ WHERE
68+ json_foo::$bar = 'foobar'
69+ ` ) ;
70+ } ) ;
71+ it ( `formats '::%' conversion path-operator without spaces` , ( ) => {
72+ expect ( format ( `SELECT * FROM foo WHERE json_foo::%bar = 'foobar'` ) ) . toBe ( dedent `
73+ SELECT
74+ *
75+ FROM
76+ foo
77+ WHERE
78+ json_foo::%bar = 'foobar'
79+ ` ) ;
80+ } ) ;
81+ } ) ;
4882} ) ;
0 commit comments