Explorar el Código

多逻辑操作符合并

myuan hace 2 años
padre
commit
51266a1643
Se han modificado 1 ficheros con 33 adiciones y 18 borrados
  1. 33 18
      run_test.py

+ 33 - 18
run_test.py

@@ -168,7 +168,7 @@ async def assert_sqls():
         ],
     )
     await assert_sql(
-        "update tb1 set col1=3 where col1=2 and col2=col3;",
+        "update tb1 set col1=3, col4=4 where col1=2 and col2=col3;",
         [
             {
                 "type": "update",
@@ -178,41 +178,56 @@ async def assert_sqls():
                         "type": "assign_const",
                         "left": {"type": "identifier", "value": "col1"},
                         "right": {"type": "int", "value": 3},
-                    }
-                ],
-                "where": [
+                    },
                     {
-                        "type": "where_condition",
+                        "type": "assign_const",
+                        "left": {"type": "identifier", "value": "col4"},
+                        "right": {"type": "int", "value": 4},
+                    },
+                ],
+                "where": {
+                    "type": "且",
+                    "left": {
+                        "type": "相等",
                         "left": {"type": "identifier", "value": "col1"},
                         "right": {"type": "int", "value": 2},
                     },
-                    {
-                        "type": "where_condition",
+                    "right": {
+                        "type": "相等",
                         "left": {"type": "identifier", "value": "col2"},
                         "right": {"type": "identifier", "value": "col3"},
                     },
-                ],
+                },
             }
         ],
     )
     await assert_sql(
-        "delete from tb1 where c1 = 1 and c2= 3;",
+        "delete from tb1 where c1 = 1 and c2= 3 or c3=3;",
         [
             {
                 "type": "delete",
                 "table_name": "tb1",
-                "where": [
-                    {
-                        "type": "where_condition",
-                        "left": {"type": "identifier", "value": "c1"},
-                        "right": {"type": "int", "value": 1},
+                "where": {
+                    "type": "或",
+                    "left": {
+                        "left": {
+                            "type": "相等",
+                            "left": {"type": "identifier", "value": "c1"},
+                            "right": {"type": "int", "value": 1},
+                        },
+                        "type": "且",
+                        "right": {
+                            "type": "相等",
+                            "left": {"type": "identifier", "value": "c2"},
+                            "right": {"type": "int", "value": 3},
+                        },
                     },
-                    {
-                        "type": "where_condition",
-                        "left": {"type": "identifier", "value": "c2"},
+                    "right": {
+                        "type": "相等",
+                        "left": {"type": "identifier", "value": "c3"},
                         "right": {"type": "int", "value": 3},
                     },
-                ],
+                },
             }
         ],
     )