Skip to content

Commit dd60722

Browse files
committed
extended sql parser
1 parent daedb68 commit dd60722

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

query_test.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,21 @@ func TestParseSelect(t *testing.T) {
274274
SQL: "SELECT t.* FROM x t WHERE 1=1 AND (x=2)",
275275
expect: "SELECT t.* FROM x t WHERE 1 = 1 AND (x=2)",
276276
},
277+
{
278+
description: "where not equal with order by",
279+
SQL: "SELECT t.* FROM x t WHERE a <> b ORDER BY c",
280+
expect: "SELECT t.* FROM x t WHERE a <> b ORDER BY c",
281+
},
282+
{
283+
description: "where not equal without spaces with order by",
284+
SQL: "SELECT t.* FROM x t WHERE a<>b ORDER BY c",
285+
expect: "SELECT t.* FROM x t WHERE a <> b ORDER BY c",
286+
},
287+
{
288+
description: "where not equal placeholder with order by",
289+
SQL: "SELECT t.* FROM x t WHERE a <> $b ORDER BY c",
290+
expect: "SELECT t.* FROM x t WHERE a <> $b ORDER BY c",
291+
},
277292

278293
{
279294
description: "func call select",

traverse.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"github.com/viant/sqlparser/update"
1313
)
1414

15-
//Traverse traverse node
15+
// Traverse traverse node
1616
func Traverse(n node.Node, visitor func(n node.Node) bool) {
1717
traverse(n, visitor)
1818
}
@@ -105,6 +105,11 @@ func traverse(n node.Node, visitor func(n node.Node) bool) bool {
105105
case *expr.Ident:
106106
case *expr.Call:
107107
traverse(actual.X, visitor)
108+
for _, arg := range actual.Args {
109+
traverse(arg, visitor)
110+
}
111+
case *expr.Collate:
112+
traverse(actual.X, visitor)
108113
case *expr.Range:
109114
traverse(actual.Min, visitor)
110115
traverse(actual.Max, visitor)

0 commit comments

Comments
 (0)