|
@@ -33,7 +33,10 @@ async def assert_sql(sql, target):
|
|
|
output = orjson.loads(stdout)
|
|
|
except Exception as e:
|
|
|
output = {"error": e, "output": stdout.decode("utf-8")}
|
|
|
-
|
|
|
+ open("/tmp/temp/test.py", "wb").write(
|
|
|
+ f'"{sql}"\n\n'.encode("utf-8")
|
|
|
+ + orjson.dumps(output, option=orjson.OPT_INDENT_2)
|
|
|
+ )
|
|
|
assert (
|
|
|
output == target
|
|
|
), f"""{colored("sql-parser error", "red")}
|
|
@@ -292,15 +295,15 @@ async def assert_sqls():
|
|
|
"type": "delete",
|
|
|
"table_name": "tb1",
|
|
|
"where": {
|
|
|
- "type": "或",
|
|
|
+ "type": "且",
|
|
|
"left": {
|
|
|
- "type": "且",
|
|
|
+ "type": "相等",
|
|
|
+ "left": {"type": "identifier", "value": "c1"},
|
|
|
+ "right": {"type": "int", "value": 1},
|
|
|
+ },
|
|
|
+ "right": {
|
|
|
+ "type": "或",
|
|
|
"left": {
|
|
|
- "type": "相等",
|
|
|
- "left": {"type": "identifier", "value": "c1"},
|
|
|
- "right": {"type": "int", "value": 1},
|
|
|
- },
|
|
|
- "right": {
|
|
|
"type": "或",
|
|
|
"left": {
|
|
|
"type": "相等",
|
|
@@ -313,11 +316,11 @@ async def assert_sqls():
|
|
|
"right": {"type": "int", "value": 3},
|
|
|
},
|
|
|
},
|
|
|
- },
|
|
|
- "right": {
|
|
|
- "type": "相等",
|
|
|
- "left": {"type": "identifier", "value": "c4"},
|
|
|
- "right": {"type": "string", "value": "'asd'"},
|
|
|
+ "right": {
|
|
|
+ "type": "相等",
|
|
|
+ "left": {"type": "identifier", "value": "c4"},
|
|
|
+ "right": {"type": "string", "value": "'asd'"},
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
}
|