|
@@ -275,7 +275,22 @@ sql_parser_tests = [
|
|
),
|
|
),
|
|
(
|
|
(
|
|
"select * from t2;",
|
|
"select * from t2;",
|
|
- [{'type': 'select_stmt', 'select_cols': [{'type': 'select_all_column', 'target': {'type': 'select_all_column', 'value': 'select_all_column'}}], 'table_names': ['t2'], 'where': {}}]
|
|
|
|
|
|
+ [
|
|
|
|
+ {
|
|
|
|
+ "type": "select_stmt",
|
|
|
|
+ "select_cols": [
|
|
|
|
+ {
|
|
|
|
+ "type": "select_all_column",
|
|
|
|
+ "target": {
|
|
|
|
+ "type": "select_all_column",
|
|
|
|
+ "value": "select_all_column",
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
|
|
+ "table_names": ["t2"],
|
|
|
|
+ "where": {},
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
),
|
|
),
|
|
(
|
|
(
|
|
"select c2 as t from t2 where col1>2;",
|
|
"select c2 as t from t2 where col1>2;",
|
|
@@ -484,7 +499,15 @@ sql_parser_tests = [
|
|
[
|
|
[
|
|
{
|
|
{
|
|
"type": "select_stmt",
|
|
"type": "select_stmt",
|
|
- "select_cols": [{'type': 'select_all_column', 'target': {'type': 'select_all_column', 'value': 'select_all_column'}}],
|
|
|
|
|
|
+ "select_cols": [
|
|
|
|
+ {
|
|
|
|
+ "type": "select_all_column",
|
|
|
|
+ "target": {
|
|
|
|
+ "type": "select_all_column",
|
|
|
|
+ "value": "select_all_column",
|
|
|
|
+ },
|
|
|
|
+ }
|
|
|
|
+ ],
|
|
"table_names": ["tb1", "tb2"],
|
|
"table_names": ["tb1", "tb2"],
|
|
"where": {},
|
|
"where": {},
|
|
}
|
|
}
|
|
@@ -497,16 +520,46 @@ sql_checker_tests = [
|
|
("create table person(name string, age int, classId int);", True),
|
|
("create table person(name string, age int, classId int);", True),
|
|
("select age from person;", True),
|
|
("select age from person;", True),
|
|
("select * from person;", True),
|
|
("select * from person;", True),
|
|
- ("select gender from person;", 'column `gender` not exists in `person`'),
|
|
|
|
|
|
+ ("select gender from person;", "column `gender` not exists in `person`"),
|
|
("select 123 from person;", True),
|
|
("select 123 from person;", True),
|
|
("drop table class;", True),
|
|
("drop table class;", True),
|
|
("create table class (id int, grade int, faculty string);", True),
|
|
("create table class (id int, grade int, faculty string);", True),
|
|
("select * from class where grade = 2 and faculty = 'Computer Science';", True),
|
|
("select * from class where grade = 2 and faculty = 'Computer Science';", True),
|
|
(
|
|
(
|
|
"select * from class where grade = 2 and count=33;",
|
|
"select * from class where grade = 2 and count=33;",
|
|
- 'column `count` not exists in `class`',
|
|
|
|
|
|
+ "column `count` not exists in `class`",
|
|
),
|
|
),
|
|
("select age, class.grade from class, person;", True),
|
|
("select age, class.grade from class, person;", True),
|
|
- ("select age, person.grade from class, person;", 'column `person.grade` not exists in `class, person`'),
|
|
|
|
|
|
+ (
|
|
|
|
+ "select age, person.grade from class, person;",
|
|
|
|
+ "column `person.grade` not exists in `class, person`",
|
|
|
|
+ ),
|
|
|
|
+ (
|
|
|
|
+ """SELECT person.name, grade, faculty
|
|
|
|
+ FROM person
|
|
|
|
+ WHERE name = '张三' and classId IN (
|
|
|
|
+ SELECT *
|
|
|
|
+ FROM class
|
|
|
|
+ WHERE class.id = classId
|
|
|
|
+ );
|
|
|
|
+ """,
|
|
|
|
+ 'column `grade` not exists in `person`',
|
|
|
|
+ ),
|
|
|
|
+ (
|
|
|
|
+ """select person.name
|
|
|
|
+ from person join class
|
|
|
|
+ on class.id=person.classId and person.grade=2
|
|
|
|
+ where age=22;
|
|
|
|
+ """,
|
|
|
|
+ "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
|
|
|
|
+ ),
|
|
|
|
|
|
]
|
|
]
|