|
@@ -23,12 +23,12 @@ async def assert_sql(sql, target):
|
|
|
stderr=subprocess.PIPE,
|
|
|
)
|
|
|
stdout, stderr = await p.communicate()
|
|
|
- if stderr:
|
|
|
- print(colored(stderr.decode("utf-8"), "yellow"))
|
|
|
if b"error" in stdout:
|
|
|
print(stdout.decode("utf-8"))
|
|
|
print(datetime.now(), "-" * 40)
|
|
|
+ print(f'other: {colored(stderr.decode("utf-8"), "yellow")}')
|
|
|
assert False, "sql-parser error"
|
|
|
+
|
|
|
try:
|
|
|
output = orjson.loads(stdout)
|
|
|
except Exception as e:
|
|
@@ -40,6 +40,8 @@ async def assert_sql(sql, target):
|
|
|
input: {colored(sql, "yellow")}
|
|
|
expect: {colored(target, "green")}
|
|
|
actual: {colored(output, "red")}
|
|
|
+other: {colored(stderr.decode("utf-8"), "yellow")}
|
|
|
+
|
|
|
"""
|
|
|
|
|
|
|
|
@@ -203,7 +205,7 @@ async def assert_sqls():
|
|
|
],
|
|
|
)
|
|
|
await assert_sql(
|
|
|
- "update tb1 set col1=3, col4=4 where not not not col1=2 and col2=4;",
|
|
|
+ "update tb1 set col1=3, col4=4 where not not not col1=2 and col2=4 or col3=col2;",
|
|
|
[
|
|
|
{
|
|
|
"type": "update",
|
|
@@ -221,25 +223,33 @@ async def assert_sqls():
|
|
|
},
|
|
|
],
|
|
|
"where": {
|
|
|
- "type": "且",
|
|
|
+ "type": "或",
|
|
|
"left": {
|
|
|
- "type": "非",
|
|
|
+ "type": "且",
|
|
|
"left": {
|
|
|
"type": "非",
|
|
|
"left": {
|
|
|
"type": "非",
|
|
|
"left": {
|
|
|
- "type": "相等",
|
|
|
- "left": {"type": "identifier", "value": "col1"},
|
|
|
- "right": {"type": "int", "value": 2},
|
|
|
+ "type": "非",
|
|
|
+ "left": {
|
|
|
+ "type": "相等",
|
|
|
+ "left": {"type": "identifier", "value": "col1"},
|
|
|
+ "right": {"type": "int", "value": 2},
|
|
|
+ },
|
|
|
},
|
|
|
},
|
|
|
},
|
|
|
+ "right": {
|
|
|
+ "type": "相等",
|
|
|
+ "left": {"type": "identifier", "value": "col2"},
|
|
|
+ "right": {"type": "int", "value": 4},
|
|
|
+ },
|
|
|
},
|
|
|
"right": {
|
|
|
"type": "相等",
|
|
|
- "left": {"type": "identifier", "value": "col2"},
|
|
|
- "right": {"type": "int", "value": 4},
|
|
|
+ "left": {"type": "identifier", "value": "col3"},
|
|
|
+ "right": {"type": "identifier", "value": "col2"},
|
|
|
},
|
|
|
},
|
|
|
}
|