You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
Copy file name to clipboardExpand all lines: engine_test.go
+103Lines changed: 103 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -113,6 +113,14 @@ var queries = []struct {
113
113
"SELECT i FROM mytable WHERE i NOT BETWEEN 1 AND 2",
114
114
[]sql.Row{{int64(3)}},
115
115
},
116
+
{
117
+
"SELECT substring(mytable.s, 1, 5) as s FROM mytable INNER JOIN othertable ON (substring(mytable.s, 1, 5) = SUBSTRING(othertable.s2, 1, 5)) GROUP BY 1",
118
+
[]sql.Row{
119
+
{"third"},
120
+
{"secon"},
121
+
{"first"},
122
+
},
123
+
},
116
124
{
117
125
"SELECT i, i2, s2 FROM mytable INNER JOIN othertable ON i = i2",
118
126
[]sql.Row{
@@ -159,6 +167,18 @@ var queries = []struct {
159
167
{int32(1), "third row"},
160
168
},
161
169
},
170
+
{
171
+
`SELECT COUNT(*) as cnt, fi FROM (
172
+
SELECT tbl.s AS fi
173
+
FROM mytable tbl
174
+
) t
175
+
GROUP BY 2`,
176
+
[]sql.Row{
177
+
{int32(1), "first row"},
178
+
{int32(1), "second row"},
179
+
{int32(1), "third row"},
180
+
},
181
+
},
162
182
{
163
183
`SELECT COUNT(*) as cnt, s as fi FROM mytable GROUP BY fi`,
164
184
[]sql.Row{
@@ -167,6 +187,14 @@ var queries = []struct {
167
187
{int32(1), "third row"},
168
188
},
169
189
},
190
+
{
191
+
`SELECT COUNT(*) as cnt, s as fi FROM mytable GROUP BY 2`,
192
+
[]sql.Row{
193
+
{int32(1), "first row"},
194
+
{int32(1), "second row"},
195
+
{int32(1), "third row"},
196
+
},
197
+
},
170
198
{
171
199
"SELECT CAST(-3 AS UNSIGNED) FROM mytable",
172
200
[]sql.Row{
@@ -296,6 +324,14 @@ var queries = []struct {
296
324
{int32(1), int64(1)},
297
325
},
298
326
},
327
+
{
328
+
`SELECT COUNT(*) c, i as foo FROM mytable GROUP BY 2 ORDER BY 2 DESC`,
329
+
[]sql.Row{
330
+
{int32(1), int64(3)},
331
+
{int32(1), int64(2)},
332
+
{int32(1), int64(1)},
333
+
},
334
+
},
299
335
{
300
336
`SELECT COUNT(*) c, i as foo FROM mytable GROUP BY i ORDER BY foo, i DESC`,
301
337
[]sql.Row{
@@ -304,6 +340,30 @@ var queries = []struct {
304
340
{int32(1), int64(1)},
305
341
},
306
342
},
343
+
{
344
+
`SELECT COUNT(*) c, i as foo FROM mytable GROUP BY 2 ORDER BY foo, i DESC`,
345
+
[]sql.Row{
346
+
{int32(1), int64(3)},
347
+
{int32(1), int64(2)},
348
+
{int32(1), int64(1)},
349
+
},
350
+
},
351
+
{
352
+
`SELECT COUNT(*) c, i as i FROM mytable GROUP BY 2`,
353
+
[]sql.Row{
354
+
{int32(1), int64(3)},
355
+
{int32(1), int64(2)},
356
+
{int32(1), int64(1)},
357
+
},
358
+
},
359
+
{
360
+
`SELECT i as i FROM mytable GROUP BY 1`,
361
+
[]sql.Row{
362
+
{int64(3)},
363
+
{int64(2)},
364
+
{int64(1)},
365
+
},
366
+
},
307
367
{
308
368
`SELECT CONCAT("a", "b", "c")`,
309
369
[]sql.Row{
@@ -370,6 +430,12 @@ var queries = []struct {
370
430
{"third row"},
371
431
},
372
432
},
433
+
{
434
+
`SELECT SUBSTRING(s, -3, 3) as s FROM mytable WHERE s LIKE '%d row' GROUP BY 1`,
435
+
[]sql.Row{
436
+
{"row"},
437
+
},
438
+
},
373
439
{
374
440
`SELECT s FROM mytable WHERE s NOT LIKE '%d row'`,
375
441
[]sql.Row{
@@ -560,6 +626,32 @@ var queries = []struct {
560
626
{"i2"},
561
627
},
562
628
},
629
+
{
630
+
`
631
+
SELECT COLUMN_NAME FROM information_schema.COLUMNS
632
+
WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME LIKE '%table'
633
+
GROUP BY 1
634
+
`,
635
+
[]sql.Row{
636
+
{"s"},
637
+
{"i"},
638
+
{"s2"},
639
+
{"i2"},
640
+
},
641
+
},
642
+
{
643
+
`
644
+
SELECT COLUMN_NAME as COLUMN_NAME FROM information_schema.COLUMNS
645
+
WHERE TABLE_SCHEMA=DATABASE() AND TABLE_NAME LIKE '%table'
0 commit comments