Skip to content

Commit 67fd354

Browse files
committed
[dev] tests for json-fields
1 parent bbb7f3a commit 67fd354

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

sql_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -134,57 +134,57 @@ var cases = [][]string{
134134
var psqlCases = [][]string{
135135
{
136136
`{ "glue":"and", "rules":[{ "field": "json:cfg.a", "condition":{ "type":"equal", "filter":1 }}]}`,
137-
"(cfg->'a')::text = $1",
137+
"(\"cfg\"->'a')::text = $1",
138138
"1",
139139
},
140140
{
141-
`{ "glue":"and", "rules":[{ "field": "json:mytable.cfg.a", "condition":{ "type":"equal", "filter":1 }}]}`,
142-
"(\"mytable\".cfg->'a')::text = $1",
141+
`{ "glue":"and", "rules":[{ "field": "mytable.json:cfg.a", "condition":{ "type":"equal", "filter":1 }}]}`,
142+
"(\"mytable\".\"cfg\"->'a')::text = $1",
143143
"1",
144144
},
145145
{
146146
`{ "glue":"and", "rules":[{ "field": "json:cfg.b:numeric", "condition":{ "type":"notEqual", "filter":1 }}]}`,
147-
"(cfg->'b')::numeric <> $1",
147+
"(\"cfg\"->'b')::numeric <> $1",
148148
"1",
149149
},
150150
{
151151
`{ "glue":"and", "rules":[{ "field": "json:cfg.b:numeric", "condition":{ "type":"less", "filter":1 }}]}`,
152-
"(cfg->'b')::numeric < $1",
152+
"(\"cfg\"->'b')::numeric < $1",
153153
"1",
154154
},
155155
{
156156
`{ "glue":"and", "rules":[{ "field": "json:cfg.b:numeric", "condition":{ "type":"lessOrEqual", "filter":1 }}]}`,
157-
"(cfg->'b')::numeric <= $1",
157+
"(\"cfg\"->'b')::numeric <= $1",
158158
"1",
159159
},
160160
{
161161
`{ "glue":"and", "rules":[{ "field": "json:cfg.b:numeric", "condition":{ "type":"greater", "filter":1 }}]}`,
162-
"(cfg->'b')::numeric > $1",
162+
"(\"cfg\"->'b')::numeric > $1",
163163
"1",
164164
},
165165
{
166166
`{ "glue":"and", "rules":[{ "field": "json:cfg.b:numeric", "condition":{ "type":"greaterOrEqual", "filter":1 }}]}`,
167-
"(cfg->'b')::numeric >= $1",
167+
"(\"cfg\"->'b')::numeric >= $1",
168168
"1",
169169
},
170170
{
171171
`{ "glue":"and", "rules":[{ "field": "json:cfg.a", "condition":{ "type":"contains", "filter":1 }}]}`,
172-
"(cfg->'a')::text LIKE '\"%' || $1 || '%\"'",
172+
"(\"cfg\"->'a')::text LIKE '\"%' || $1 || '%\"'",
173173
"1",
174174
},
175175
{
176176
`{ "glue":"and", "rules":[{ "field": "json:cfg.a", "condition":{ "type":"notContains", "filter":1 }}]}`,
177-
"(cfg->'a')::text NOT LIKE '\"%' || $1 || '%\"'",
177+
"(\"cfg\"->'a')::text NOT LIKE '\"%' || $1 || '%\"'",
178178
"1",
179179
},
180180
{
181181
`{ "glue":"and", "rules":[{ "field": "json:cfg.c:date", "condition":{ "type":"equal", "filter":"2006/01/02" }}]}`,
182-
"CAST((cfg->'c')::text AS DATE) = $1",
182+
"CAST((\"cfg\"->'c')::text AS DATE) = $1",
183183
`2006/01/02`,
184184
},
185185
{
186186
`{ "glue":"and", "rules":[{ "field": "json:cfg.c:date", "condition":{ "type":"notBetween", "filter":{ "start":"2006/01/02", "end":"2006/01/9" } }}]}`,
187-
"( CAST((cfg->'c')::text AS DATE) < $1 OR CAST((cfg->'c')::text AS DATE) > $2 )",
187+
"( CAST((\"cfg\"->'c')::text AS DATE) < $1 OR CAST((\"cfg\"->'c')::text AS DATE) > $2 )",
188188
`2006/01/02,2006/01/9`,
189189
},
190190
}

0 commit comments

Comments
 (0)