MCPcopy Create free account
hub / github.com/bytebase/bytebase / TestGetStatementWithResultLimit

Function TestGetStatementWithResultLimit

backend/plugin/db/mysql/query_test.go:9–219  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

7)
8
9func TestGetStatementWithResultLimit(t *testing.T) {
10 testCases := []struct {
11 stmt string
12 count int
13 want string
14 }{
15 {
16 stmt: "SELECT * FROM t LIMIT 0,20;",
17 count: 10,
18 want: "SELECT * FROM t LIMIT 0,10;",
19 },
20 {
21 stmt: "SELECT * FROM t LIMIT 123,20;",
22 count: 10,
23 want: "SELECT * FROM t LIMIT 123,10;",
24 },
25 {
26 stmt: "SELECT * FROM t;",
27 count: 10,
28 want: "SELECT * FROM t LIMIT 10;",
29 },
30 {
31 stmt: "SELECT * FROM t LIMIT 10;",
32 count: 5,
33 want: "SELECT * FROM t LIMIT 5;",
34 },
35 {
36 stmt: "SELECT * FROM t LIMIT 5;",
37 count: 10,
38 want: "SELECT * FROM t LIMIT 5;",
39 },
40 {
41 stmt: "SELECT * FROM t LIMIT 0;",
42 count: 10,
43 want: "SELECT * FROM t LIMIT 0;",
44 },
45 {
46 stmt: "SELECT * FROM t LIMIT 123;",
47 count: 10,
48 want: "SELECT * FROM t LIMIT 10;",
49 },
50 {
51 stmt: "SELECT * FROM t LIMIT 10 OFFSET 123;",
52 count: 5,
53 want: "SELECT * FROM t LIMIT 5 OFFSET 123;",
54 },
55 {
56 stmt: "SELECT * FROM t2 JOIN t1 ON t2.c2 = t1.c2 where t2.c2 > 10;",
57 count: 10,
58 want: "SELECT * FROM t2 JOIN t1 ON t2.c2 = t1.c2 where t2.c2 > 10 LIMIT 10;",
59 },
60 {
61 stmt: "SELECT * FROM t1 ORDER BY c2;",
62 count: 10,
63 want: "SELECT * FROM t1 ORDER BY c2 LIMIT 10;",
64 },
65 {
66 stmt: "SELECT COUNT(col1) AS col2 FROM t GROUP BY col2 HAVING col2 = 2;",

Callers

nothing calls this directly

Calls 2

EqualMethod · 0.65

Tested by

no test coverage detected