|
@@ -144,12 +144,15 @@ sql_parser_tests = [
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "col1"},
|
|
|
"right": {"type": "int", "value": 2},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "col2"},
|
|
|
"right": {"type": "int", "value": 4},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -186,6 +189,7 @@ sql_parser_tests = [
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "col1"},
|
|
|
"right": {"type": "int", "value": 2},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
},
|
|
|
},
|
|
@@ -194,13 +198,17 @@ sql_parser_tests = [
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "col2"},
|
|
|
"right": {"type": "int", "value": 4},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "col3"},
|
|
|
"right": {"type": "identifier", "value": "col2"},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -214,23 +222,28 @@ sql_parser_tests = [
|
|
|
"where": {
|
|
|
"type": "或",
|
|
|
"left": {
|
|
|
+ "type": "且",
|
|
|
"left": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "c1"},
|
|
|
"right": {"type": "int", "value": 1},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
- "type": "且",
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "c2"},
|
|
|
"right": {"type": "int", "value": 3},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "c3"},
|
|
|
"right": {"type": "int", "value": 3},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -249,6 +262,7 @@ sql_parser_tests = [
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "c1"},
|
|
|
"right": {"type": "int", "value": 1},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "或",
|
|
@@ -256,19 +270,25 @@ sql_parser_tests = [
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "c2"},
|
|
|
"right": {"type": "int", "value": 3},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "c3"},
|
|
|
"right": {"type": "int", "value": 3},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "identifier", "value": "c4"},
|
|
|
"right": {"type": "string", "value": "'asd'"},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -309,6 +329,7 @@ sql_parser_tests = [
|
|
|
"type": "大于",
|
|
|
"left": {"type": "identifier", "value": "col1"},
|
|
|
"right": {"type": "int", "value": 2},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -334,6 +355,7 @@ sql_parser_tests = [
|
|
|
{"type": "int", "value": 1},
|
|
|
{"type": "int", "value": 2},
|
|
|
],
|
|
|
+ "op_type": "bin_contains_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "包含于",
|
|
@@ -343,7 +365,9 @@ sql_parser_tests = [
|
|
|
{"type": "int", "value": 4},
|
|
|
{"type": "int", "value": 5},
|
|
|
],
|
|
|
+ "op_type": "bin_contains_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -391,8 +415,10 @@ sql_parser_tests = [
|
|
|
"field": "Cno",
|
|
|
},
|
|
|
"right": {"type": "string", "value": "'81003'"},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
},
|
|
|
+ "op_type": "bin_contains_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -429,12 +455,14 @@ sql_parser_tests = [
|
|
|
"field": "Sno",
|
|
|
},
|
|
|
"right": {"type": "table_field", "table": "SC", "field": "Sno"},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
},
|
|
|
"where": {
|
|
|
"type": "相等",
|
|
|
"left": {"type": "table_field", "table": "SC", "field": "Cno"},
|
|
|
"right": {"type": "string", "value": "'81003'"},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
}
|
|
|
],
|
|
@@ -477,6 +505,7 @@ sql_parser_tests = [
|
|
|
"table": "SC",
|
|
|
"field": "Sno",
|
|
|
},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
@@ -486,7 +515,9 @@ sql_parser_tests = [
|
|
|
"field": "Cno",
|
|
|
},
|
|
|
"right": {"type": "string", "value": "'81003'"},
|
|
|
+ "op_type": "bin_cmp_op",
|
|
|
},
|
|
|
+ "op_type": "bin_logical_op",
|
|
|
},
|
|
|
},
|
|
|
"where": {},
|
|
@@ -543,7 +574,7 @@ sql_checker_tests = [
|
|
|
WHERE class.id = classId
|
|
|
);
|
|
|
""",
|
|
|
- 'column `grade` not exists in `person`',
|
|
|
+ "column `grade` not exists in `person`",
|
|
|
),
|
|
|
(
|
|
|
"""select person.name
|
|
@@ -553,13 +584,20 @@ sql_checker_tests = [
|
|
|
""",
|
|
|
"column `person.grade` not exists in `person, class`",
|
|
|
),
|
|
|
- (
|
|
|
+ (
|
|
|
"""select person.name
|
|
|
from person join class
|
|
|
on class.id=person.classId and class.grade=2
|
|
|
where age=22;
|
|
|
""",
|
|
|
- True
|
|
|
+ True,
|
|
|
+ ),
|
|
|
+ (
|
|
|
+ """select person.name
|
|
|
+ from person join class
|
|
|
+ on class.id=person.classId and class.grade = 'zxc'
|
|
|
+ where age=22;
|
|
|
+ """,
|
|
|
+ True,
|
|
|
),
|
|
|
-
|
|
|
]
|