@@ -9,6 +9,7 @@ import supportsCreateTable from './features/createTable.js';
9
9
import supportsCreateView from './features/createView.js' ;
10
10
import supportsAlterTable from './features/alterTable.js' ;
11
11
import supportsStrings from './features/strings.js' ;
12
+ import dedent from 'dedent-js' ;
12
13
13
14
describe ( 'SingleStoreDbFormatter' , ( ) => {
14
15
const language = 'singlestoredb' ;
@@ -45,4 +46,67 @@ describe('SingleStoreDbFormatter', () => {
45
46
modify : true ,
46
47
renameTo : true ,
47
48
} ) ;
49
+ // it('allows operations in BETWEEN ranges', () => {
50
+ // expect(format('SELECT SUM(extendedprice * discount) AS revenue FROM item WHERE discount BETWEEN 0.06 - 0.01 AND 0.06 + 0.01')).toBe(dedent`
51
+ // SELECT
52
+ // SUM(extendedprice * discount) AS revenue
53
+ // FROM
54
+ // item
55
+ // WHERE
56
+ // discount BETWEEN 0.06 - 0.01 AND 0.06 + 0.01
57
+ // `);
58
+ // });
59
+ describe ( `formats traversal of semi structured data` , ( ) => {
60
+ it ( `formats '.' path-operator without spaces` , ( ) => {
61
+ expect ( format ( `SELECT TO_JSON(foo.*) AS foo_json FROM foo` ) ) . toBe ( dedent `
62
+ SELECT
63
+ TO_JSON(foo.*) AS foo_json
64
+ FROM
65
+ foo
66
+ ` ) ;
67
+ } ) ;
68
+ it ( `formats '::' path-operator without spaces` , ( ) => {
69
+ expect ( format ( `SELECT * FROM foo WHERE json_foo::bar = 'foobar'` ) ) . toBe ( dedent `
70
+ SELECT
71
+ *
72
+ FROM
73
+ foo
74
+ WHERE
75
+ json_foo::bar = 'foobar'
76
+ ` ) ;
77
+ } ) ;
78
+ it ( `formats '::$' conversion path-operator without spaces` , ( ) => {
79
+ expect ( format ( `SELECT * FROM foo WHERE json_foo::$bar = 'foobar'` ) ) . toBe ( dedent `
80
+ SELECT
81
+ *
82
+ FROM
83
+ foo
84
+ WHERE
85
+ json_foo::$bar = 'foobar'
86
+ ` ) ;
87
+ } ) ;
88
+ it ( `formats '::%' conversion path-operator without spaces` , ( ) => {
89
+ expect ( format ( `SELECT * FROM foo WHERE json_foo::%bar = 'foobar'` ) ) . toBe ( dedent `
90
+ SELECT
91
+ *
92
+ FROM
93
+ foo
94
+ WHERE
95
+ json_foo::%bar = 'foobar'
96
+ ` ) ;
97
+ } ) ;
98
+ } ) ;
99
+ describe ( `formats custom type-cast operators` , ( ) => {
100
+ it ( `formats ':>' type-cast operator` , ( ) => {
101
+ expect ( format ( `SELECT 1 :> DOUBLE AS foo` ) ) . toBe ( dedent `
102
+ SELECT
103
+ 1 :> DOUBLE AS foo
104
+ ` ) ;
105
+ expect ( format ( `SELECT 1 !:> DOUBLE AS foo` ) ) . toBe ( dedent `
106
+ SELECT
107
+ 1 !:> DOUBLE AS foo
108
+ ` ) ;
109
+ } ) ;
110
+ } ) ;
111
+
48
112
} ) ;
0 commit comments