Fix the binop leg of the parser to correctly consider only a single LHS node
[dbsrgits/SQL-Abstract.git] / t / 11parser.t
index 7cf6509..5ce1a80 100644 (file)
@@ -533,6 +533,50 @@ is_deeply($sqlat->parse( "SELECT [screen].[id], [screen].[name], [screen].[secti
   ]
 ], 'real life statement 1 parsed correctly');
 
+is_deeply($sqlat->parse("CASE WHEN FOO() > BAR()"), [
+  [
+    "-MISC",
+    [
+      [
+        "-LITERAL",
+        [
+          "CASE"
+        ]
+      ],
+      [
+        "-LITERAL",
+        [
+          "WHEN"
+        ]
+      ]
+    ]
+  ],
+  [
+    ">",
+    [
+      [
+        "FOO",
+        [
+          [
+            "-PAREN",
+            []
+          ]
+        ]
+      ],
+      [
+        "BAR",
+        [
+          [
+            "-PAREN",
+            []
+          ]
+        ]
+      ]
+    ]
+  ]
+]);
+
+
 is_deeply($sqlat->parse("SELECT x, y FROM foo WHERE x IN (?, ?, ?, ?)"), [
   [
     "SELECT",
@@ -811,7 +855,7 @@ is_deeply($sqlat->parse('SELECT foo FROM bar ORDER BY x + ? DESC, oomph, y - ? D
   ]
 ], 'Crazy ORDER BY parsed correctly');
 
-is_deeply( $sqlat->parse("META SELECT * * FROM (SELECT *, FROM foobar baz buzz) foo bar WHERE NOT NOT NOT EXISTS (SELECT 'cr,ap') AND foo.a = ? STUFF moar(stuff) and not (foo.b LIKE 'station') and x = y and a = b and GROUP BY , ORDER BY x x1 x2 y asc, max(y) desc x z desc"), [
+is_deeply( $sqlat->parse("META SELECT * * FROM (SELECT *, FROM foobar baz buzz) foo bar WHERE NOT NOT NOT EXISTS (SELECT 'cr,ap') AND foo.a = ? STUFF moar(stuff) and not (foo.b LIKE 'station') and x = y and z in ((1, 2)) and a = b and GROUP BY , ORDER BY x x1 x2 y asc, max(y) desc x z desc"), [
   [
     "-LITERAL",
     [
@@ -1047,6 +1091,44 @@ is_deeply( $sqlat->parse("META SELECT * * FROM (SELECT *, FROM foobar baz buzz)
             ]
           ],
           [
+            'IN',
+            [
+              [
+                '-LITERAL',
+                [
+                  'z',
+                ],
+              ],
+              [
+                '-PAREN',
+                [
+                  [
+                    '-PAREN',
+                    [
+                      [
+                        '-LIST',
+                        [
+                          [
+                            '-LITERAL',
+                            [
+                              '1'
+                            ]
+                          ],
+                          [
+                            '-LITERAL',
+                            [
+                              '2'
+                            ]
+                          ],
+                        ],
+                      ],
+                    ],
+                  ],
+                ],
+              ],
+            ],
+          ],
+          [
             "=",
             [
               [