mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-09-11 11:55:33 +03:00
working on group-by, all tests pass
This commit is contained in:
parent
55ecf069b9
commit
06919ed971
@ -12,6 +12,7 @@ FROM [ <ship-qualifer> ]<table-view> [ [AS] <alias> ]
|
||||
| CROSS JOIN
|
||||
[ <ship-qualifer> ]<table-view> [ [AS] <alias> ]
|
||||
]
|
||||
[ GROUP BY { <qualified-column> | <column-alias> | <column-ordinal> } [ ,...n ] ]
|
||||
[ { SCALAR <scalar-name> [ AS ] <scalar-function> } [ ...n ] ]
|
||||
[ WHERE <predicate> ]
|
||||
SELECT [ TOP <n> ] [ BOTTOM <n> ] [ DISTINCT ]
|
||||
@ -21,8 +22,6 @@ SELECT [ TOP <n> ] [ BOTTOM <n> ] [ DISTINCT ]
|
||||
| <aggregate-name>( { <column> | <scalar-name> } )
|
||||
} [ ,...n ]
|
||||
}
|
||||
[ GROUP BY { <qualified-column> | <column-alias> | <column-ordinal> } [ ,...n ]
|
||||
[ HAVING <predicate> ] ]
|
||||
[ ORDER BY { { <qualified-column> | <column-alias> | <column-ordinal> }
|
||||
[ ASC | DESC ] } [ ,...n ] ]
|
||||
[ INTO <table> ]
|
||||
|
@ -58,6 +58,7 @@
|
||||
+$ parens ?(%pal %par)
|
||||
+$ raw-predicate-component ?(parens predicate-component:ast predicate:ast)
|
||||
+$ raw-predicate-component2 ?(parens predicate-component:ast)
|
||||
+$ group-by-list (list grouping-column:ast)
|
||||
::
|
||||
:: get next position in script
|
||||
::
|
||||
@ -449,6 +450,7 @@
|
||||
::
|
||||
++ join-stop ;~ pose
|
||||
;~(plug (jester 'scalar') whitespace)
|
||||
;~(plug (jester 'group') whitespace)
|
||||
;~(plug (jester 'select') whitespace)
|
||||
;~(plug (jester 'join') whitespace)
|
||||
;~(plug (jester 'left') whitespace)
|
||||
@ -683,26 +685,26 @@
|
||||
parsed +>.parsed
|
||||
==
|
||||
~|("invalid compbination of unary operators {<-.working-tree>} and {<-.parsed>}" !!)
|
||||
?~ r.working-tree ~|("unary-operator, right tree empty" !!)
|
||||
~|("unary-operator can't get here" !!)
|
||||
?~ r.working-tree ~|("unary-operator, right tree empty {<working-tree>}" !!)
|
||||
~|("unary-operator can't get here {<working-tree>}" !!)
|
||||
binary-operator:ast
|
||||
?~ working-tree !!
|
||||
?~ l.working-tree ~|("binary-operator, left tree empty" !!)
|
||||
?~ r.working-tree ~|("binary-operator, right tree empty" !!)
|
||||
?~ l.working-tree ~|("binary-operator, left tree empty {<working-tree>}" !!)
|
||||
?~ r.working-tree ~|("binary-operator, right tree empty {<working-tree>}" !!)
|
||||
~|("binary-operator can't get here {<working-tree>}" !!)
|
||||
ternary-operator:ast
|
||||
?~ working-tree !!
|
||||
?~ l.working-tree ~|("ternary-operator, left tree empty" !!)
|
||||
?~ r.working-tree ~|("ternary-operator, right tree empty" !!)
|
||||
~|("ternary-operator can't get here" !!)
|
||||
?~ l.working-tree ~|("ternary-operator, left tree empty {<working-tree>}" !!)
|
||||
?~ r.working-tree ~|("ternary-operator, right tree empty {<working-tree>}" !!)
|
||||
~|("ternary-operator can't get here {<working-tree>}" !!)
|
||||
conjunction:ast
|
||||
?~ working-tree
|
||||
%= $
|
||||
working-tree [-.parsed ~ ~]
|
||||
parsed +.parsed
|
||||
==
|
||||
?~ l.working-tree ~|("conjunction, left tree empty" !!)
|
||||
?~ r.working-tree ~|("conjunction, right tree empty" !!)
|
||||
?~ l.working-tree ~|("conjunction, left tree empty {<working-tree>}" !!)
|
||||
?~ r.working-tree ~|("conjunction, right tree empty {<working-tree>}" !!)
|
||||
%= $
|
||||
working-tree [-.parsed working-tree ~]
|
||||
parsed +.parsed
|
||||
@ -716,7 +718,7 @@
|
||||
working-tree [-.working-tree +<.working-tree [-.parsed [+<.parsed ~ ~] ~]]
|
||||
parsed +>.parsed
|
||||
==
|
||||
?: ?=(qualified-column:ast +<.parsed) :: to do: this must resolve to a CTE or list
|
||||
?: ?=(qualified-column:ast +<.parsed)
|
||||
%= $
|
||||
working-tree [-.working-tree +<.working-tree [-.parsed [+<.parsed ~ ~] ~]]
|
||||
parsed +>.parsed
|
||||
@ -954,14 +956,7 @@
|
||||
::
|
||||
:: select
|
||||
::
|
||||
++ select-stop ;~ plug
|
||||
whitespace
|
||||
;~ pose
|
||||
(jester 'top')
|
||||
(jester 'bottom')
|
||||
;~(plug (jester 'top') whitespace dem whitespace (jester 'bottom'))
|
||||
==
|
||||
==
|
||||
++ select-stop ;~(plug (jester 'order') whitespace (jester 'by'))
|
||||
++ parse-alias-all (stag %all-columns ;~(sfix parse-alias ;~(plug dot tar)))
|
||||
++ parse-object-all (stag %all-columns ;~(sfix parse-qualified-object ;~(plug dot tar)))
|
||||
++ parse-selection ~+ ;~ pose
|
||||
@ -973,7 +968,7 @@
|
||||
;~(pose parse-qualified-column parse-value-literal)
|
||||
(cold %all tar)
|
||||
==
|
||||
++ select-column :: ifix is faster here than pose pfix sfix whitespace
|
||||
++ select-column
|
||||
(ifix [whitespace whitespace] parse-selection)
|
||||
++ select-columns ;~ pose
|
||||
(full (more com select-column))
|
||||
@ -1039,6 +1034,7 @@
|
||||
++ parse-grouping-column (ifix [whitespace whitespace] ;~(pose parse-qualified-column dem))
|
||||
++ parse-group-by ;~ plug
|
||||
(cold %group-by ;~(plug whitespace (jester 'group') whitespace (jester 'by')))
|
||||
:: (cold %group-by ;~(plug (jester 'group') whitespace (jester 'by')))
|
||||
(more com parse-grouping-column)
|
||||
==
|
||||
++ cook-ordering-column
|
||||
@ -1147,14 +1143,6 @@
|
||||
a +.a
|
||||
==
|
||||
?> ?=(qualified-column:ast -.a) $(columns [-.a columns], a +.a)
|
||||
++ build-simple-query
|
||||
|= a=[from=(unit from:ast) scalars=(list scalar-function:ast) predicate=(unit predicate:ast) select=select:ast group-by=(unit group-by:ast) having=(unit having:ast) order-by=(unit order-by:ast)]
|
||||
^- simple-query:ast
|
||||
=/ priori=(unit priori:ast) ?: ?&(=(from.a ~) =(scalars.a ~) =(predicate.a ~)) ~
|
||||
`(priori:ast %priori from.a scalars.a predicate.a)
|
||||
=/ posteriori=(unit posteriori:ast) ?: ?&(=(group-by.a ~) =(having.a ~) =(order-by.a ~)) ~
|
||||
`(posteriori:ast %posteriori group-by.a having.a order-by.a)
|
||||
(simple-query:ast %simple-query priori select.a posteriori)
|
||||
++ produce-simple-query
|
||||
|= a=(list *)
|
||||
^- simple-query:ast
|
||||
@ -1162,19 +1150,18 @@
|
||||
=/ scalars=(list scalar-function:ast) ~
|
||||
=/ predicate=(unit predicate:ast) ~
|
||||
=/ select=(unit select:ast) ~
|
||||
=/ group-by=(unit group-by:ast) ~
|
||||
=/ having=(unit having:ast) ~
|
||||
=/ group-by=(list grouping-column:ast) ~
|
||||
=/ order-by=(unit order-by:ast) ~
|
||||
|-
|
||||
?~ a ~|("cannot parse simple-query {<a>}" !!)
|
||||
?: =(i.a %query) $(a t.a)
|
||||
?: =(i.a %end-command) (build-simple-query [from scalars predicate (need select) group-by having order-by])
|
||||
?: =(i.a %end-command)
|
||||
(simple-query:ast %simple-query from [%group-by group-by] [%scalars scalars] predicate (need select) order-by)
|
||||
::?: =(i.a %scalars) $(a t.a, scalars +.i.a)
|
||||
?: =(-<.a %scalars) $(a t.a, scalars ~)
|
||||
?: =(-<.a %where) $(a t.a, predicate `(produce-predicate (predicate-list +.i.a)))
|
||||
?: =(-<.a %select) $(a t.a, select `(produce-select +.i.a))
|
||||
?: =(-<.a %group-by) $(a t.a, group-by ~)
|
||||
?: =(-<.a %having) $(a t.a, having ~)
|
||||
?: =(-<.a %group-by) $(a t.a, group-by (group-by-list ->+.a))
|
||||
?: =(-<.a %order-by) $(a t.a, order-by ~)
|
||||
?: =(-<-.a %query-object) $(a t.a, from `(produce-from i.a))
|
||||
~|("cannot parse simple-query {<a>}" !!)
|
||||
@ -1252,21 +1239,35 @@
|
||||
==
|
||||
++ parse-query1 ;~ plug
|
||||
parse-object-and-joins
|
||||
parse-group-by
|
||||
:: (stag %scalars (star parse-scalar))
|
||||
;~(pfix whitespace ;~(plug (cold %where (jester 'where')) parse-predicate))
|
||||
parse-select
|
||||
:: parse-group-by
|
||||
:: parse-order-by
|
||||
end-or-next-command
|
||||
==
|
||||
++ parse-query2 ;~ plug
|
||||
parse-object-and-joins
|
||||
:: (stag %scalars (star parse-scalar))
|
||||
;~(pfix whitespace ;~(plug (cold %where (jester 'where')) parse-predicate))
|
||||
parse-select
|
||||
:: parse-group-by
|
||||
:: parse-order-by
|
||||
end-or-next-command
|
||||
==
|
||||
++ parse-query3 ;~ plug
|
||||
parse-object-and-joins
|
||||
parse-group-by
|
||||
:: (stag %scalars (star parse-scalar))
|
||||
parse-select
|
||||
|
||||
:: parse-order-by
|
||||
end-or-next-command
|
||||
==
|
||||
++ parse-query4 ;~ plug
|
||||
parse-object-and-joins
|
||||
parse-select
|
||||
end-or-next-command
|
||||
==
|
||||
++ parse-query9 ;~ plug
|
||||
parse-select
|
||||
end-or-next-command
|
||||
@ -1274,6 +1275,8 @@
|
||||
++ parse-query ;~ pose
|
||||
parse-query1
|
||||
parse-query2
|
||||
parse-query3
|
||||
parse-query4
|
||||
parse-query9
|
||||
==
|
||||
++ parse-revoke ;~ plug
|
||||
@ -1665,14 +1668,15 @@
|
||||
==
|
||||
~|("Cannot parse insert {<parsed>}" !!)
|
||||
%query
|
||||
~| "Cannot parse query {<p.q.command-nail>}"
|
||||
~| "q.q.command-nail: {<q.q.command-nail>}"
|
||||
~| "Cannot parse query {<q.q.command-nail>}"
|
||||
~| "command-nail: {<command-nail>}"
|
||||
=/ query-nail (parse-query [[1 1] q.q.command-nail])
|
||||
~| "query-nail: {<query-nail>}"
|
||||
=/ parsed (wonk query-nail)
|
||||
=/ next-cursor
|
||||
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:query-nail])
|
||||
:: ~| "parsed: {<parsed>}"
|
||||
:: ~| "remainder: {<q.q.u.+3:q.+3.query-nail>}"
|
||||
~| "parsed: {<parsed>}"
|
||||
~| "remainder: {<q.q.u.+3:q.+3.query-nail>}"
|
||||
%= $
|
||||
script q.q.u.+3.q:query-nail
|
||||
script-position next-cursor
|
||||
|
@ -125,22 +125,11 @@
|
||||
+$ simple-query
|
||||
$:
|
||||
%simple-query
|
||||
(unit priori)
|
||||
select
|
||||
(unit posteriori)
|
||||
==
|
||||
+$ priori
|
||||
$:
|
||||
%priori
|
||||
(unit from)
|
||||
(list scalar-function)
|
||||
[%group-by (list grouping-column)]
|
||||
[%scalars (list scalar-function)]
|
||||
(unit predicate)
|
||||
==
|
||||
+$ posteriori
|
||||
$:
|
||||
%posteriori
|
||||
(unit group-by)
|
||||
(unit having)
|
||||
select
|
||||
(unit order-by)
|
||||
==
|
||||
+$ from
|
||||
@ -205,8 +194,6 @@
|
||||
grouping-column
|
||||
is-ascending=?
|
||||
==
|
||||
+$ group-by (list grouping-column)
|
||||
+$ having predicate
|
||||
+$ order-by (list ordering-column)
|
||||
+$ cte-query
|
||||
$:
|
||||
@ -215,7 +202,7 @@
|
||||
simple-query
|
||||
==
|
||||
+$ ctes
|
||||
(map @t cte-query) :: common table expressions
|
||||
(list cte-query) :: common table expressions
|
||||
+$ query
|
||||
$:((unit ctes) simple-query) :: what we've all been waiting for
|
||||
::
|
||||
|
@ -16,22 +16,298 @@
|
||||
::
|
||||
:: -test /=urql=/tests/lib/parse/hoon ~
|
||||
|%
|
||||
:: re-used components
|
||||
++ all-columns [%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']
|
||||
++ foo
|
||||
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo'] 'foo' ~] ~ ~]
|
||||
++ t1-foo
|
||||
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'T1'] 'foo' ~] ~ ~]
|
||||
|
||||
++ foo2 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo2'] 'foo2' ~] ~ ~]
|
||||
++ t1-foo2 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'T1'] 'foo2' ~] ~ ~]
|
||||
++ foo3 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo3'] 'foo3' ~] ~ ~]
|
||||
++ t1-foo3 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'T1'] 'foo3' ~] ~ ~]
|
||||
++ foo4 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo4'] 'foo4' ~] ~ ~]
|
||||
++ foo5 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo5'] 'foo5' ~] ~ ~]
|
||||
++ foo6 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo6'] 'foo6' ~] ~ ~]
|
||||
++ foo7 [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo7'] 'foo7' ~] ~ ~]
|
||||
++ bar
|
||||
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'bar'] 'bar' ~] ~ ~]
|
||||
++ t2-bar
|
||||
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'T2'] 'bar' ~] ~ ~]
|
||||
|
||||
++ foobar [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foobar'] 'foobar' ~] ~ ~]
|
||||
|
||||
++ a1-adoption-email [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A1'] 'adoption-email' ~] ~ ~]
|
||||
++ a2-adoption-email [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A2'] 'adoption-email' ~] ~ ~]
|
||||
|
||||
++ a1-adoption-date [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A1'] 'adoption-date' ~] ~ ~]
|
||||
++ a2-adoption-date [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A2'] 'adoption-date' ~] ~ ~]
|
||||
|
||||
++ a1-name [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A1'] 'name' ~] ~ ~]
|
||||
++ a2-name [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A2'] 'name' ~] ~ ~]
|
||||
++ a1-species [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A1'] 'species' ~] ~ ~]
|
||||
++ a2-species [[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'A2'] 'species' ~] ~ ~]
|
||||
|
||||
++ value-literal-list [[%value-literal-list %ud '3;2;1'] ~ ~]
|
||||
++ aggregate-count-foo [%aggregate %count %qualified-column [%qualified-object 0 'UNKNOWN' 'COLUMN-OR-CTE' %foo] %foo 0]
|
||||
++ literal-10 [[%ud 10] 0 0]
|
||||
::
|
||||
|
||||
|
||||
++ aliased-joins-bar-baz
|
||||
~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=[~ 'B1']] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]] [%joined-object join=%left-join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='baz'] alias=[~ 'b2']] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]]]
|
||||
++ aliased-foo-join-bar-baz
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=[~ 'f1']] joins=aliased-joins-bar-baz]]
|
||||
++ aliased-from-foo-join-bar-baz
|
||||
[%simple-query [~ [%priori aliased-foo-join-bar-baz ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
|
||||
|
||||
:: re-used simple predicates
|
||||
++ foobar-gte-foo [%gte foobar foo]
|
||||
++ foobar-lte-bar [%lte foobar bar]
|
||||
++ foo-eq-1 [%eq foo [[%ud 1] ~ ~]]
|
||||
++ t1-foo-gt-foo2 [%gt t1-foo foo2]
|
||||
++ t2-bar-in-list [%in t2-bar value-literal-list]
|
||||
++ t1-foo2-eq-zod [%eq t1-foo2 [[%p 0] ~ ~]]
|
||||
++ t1-foo3-lt-any-list [%lt t1-foo3 [%any value-literal-list ~]]
|
||||
::
|
||||
:: from foo (aliased) join bar (aliased) left join baz (aliased)
|
||||
++ test-from-join-09
|
||||
%+ expect-eq
|
||||
!> ~[aliased-from-foo-join-bar-baz]
|
||||
!> (parse:parse(current-database 'db1') "FROM foo f1 join bar as B1 on 1 = 1 left join baz b2 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
||||
:: re-used predicates with conjunctions
|
||||
++ and-fb-gte-f--fb-lte-b [%and foobar-gte-foo foobar-lte-bar]
|
||||
++ and-fb-gte-f--t1f2-eq-z [%and foobar-gte-foo t1-foo2-eq-zod]
|
||||
++ and-f-eq-1--t1f3-lt-any [%and foo-eq-1 t1-foo3-lt-any-list]
|
||||
++ and-and [%and and-fb-gte-f--fb-lte-b t1-foo2-eq-zod]
|
||||
++ and-and-or [%or and-and t2-bar-in-list]
|
||||
++ and-and-or-and [%or and-and and-fb-gte-f--t1f2-eq-z]
|
||||
++ and-and-or-and-or-and [%or and-and-or-and and-f-eq-1--t1f3-lt-any]
|
||||
::
|
||||
:: predicates with conjunctions and nesting
|
||||
++ and-fb-gt-f--fb-lt-b [%and [%gt foobar foo] [%lt foobar bar]]
|
||||
++ and-t1f-gt-f2--t2b-in-l [%and t1-foo-gt-foo2 t2-bar-in-list]
|
||||
++ or2 [%and [%and t1-foo3-lt-any-list t1-foo2-eq-zod] foo-eq-1]
|
||||
++ or3 [%and [%eq foo3 foo4] [%eq foo5 foo6]]
|
||||
++ big-or [%or [%or [%or and-t1f-gt-f2--t2b-in-l or2] or3] [%eq foo4 foo5]]
|
||||
++ big-and [%and and-fb-gt-f--fb-lt-b big-or]
|
||||
++ a-a-l-a-o-l-a-a-r-o-r-a-l-o-r-a
|
||||
[%and big-and [%eq foo6 foo7]]
|
||||
++ first-or [%or [%gt foobar foo] [%lt foobar bar]]
|
||||
++ last-or [%or t1-foo3-lt-any-list [%and t1-foo2-eq-zod foo-eq-1]]
|
||||
++ first-and [%and first-or t1-foo-gt-foo2]
|
||||
++ second-and [%and first-and t2-bar-in-list]
|
||||
++ king-and [%and [second-and] last-or]
|
||||
::
|
||||
:: test binary operators, varying spacing
|
||||
|
||||
++ test-predicate-01
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-02
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo<>bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%neq foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-03
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo!= bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%neq foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-04
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo >bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%gt foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-05
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo <bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%lt foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-06
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo>= bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%gte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-07
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo!< bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%gte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-08
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo <= bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%lte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-09
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo !> bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%lte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
::
|
||||
:: remaining simple predicates, varying spacing and keywork casing
|
||||
++ test-predicate-10
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE foobar Not Between foo And bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%between foobar-gte-foo foobar-lte-bar] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-11
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE foobar Not Between foo bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%between foobar-gte-foo foobar-lte-bar] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-12
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE foobar Between foo And bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%between foobar-gte-foo foobar-lte-bar]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-13
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE foobar between foo And bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%between foobar-gte-foo foobar-lte-bar]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-14
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE T1.foo>=aLl bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%gte t1-foo [%all bar ~]]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-15
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE T1.foo nOt In bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%in t1-foo bar] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-16
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE T1.foo not in (1,2,3) ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%in t1-foo value-literal-list] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-17
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE T1.foo in bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%in t1-foo bar]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-18
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE T1.foo in (1,2,3) ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%in t1-foo value-literal-list]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-19
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE NOT EXISTS T1.foo ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%exists t1-foo ~] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-20
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE NOT exists foo ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%exists foo ~] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-21
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE EXISTS T1.foo ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%exists t1-foo ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-22
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE EXISTS foo ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%exists foo ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
::
|
||||
:: test conjunctions, varying spacing and keyword casing
|
||||
++ test-predicate-23
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar ".
|
||||
" WHERE foobar >=foo And foobar<=bar ".
|
||||
" SELECT *"
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) and-fb-gte-f--fb-lte-b
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
|
||||
--
|
@ -916,42 +916,42 @@
|
||||
::
|
||||
:: from object and joins
|
||||
::
|
||||
++ from-foo
|
||||
++ from-foo
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=~]]
|
||||
++ from-foo-aliased
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=[~ 'F1']] joins=~]]
|
||||
++ simple-from-foo
|
||||
[%simple-query [~ [%priori from-foo ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ aliased-from-foo
|
||||
[%simple-query [~ [%priori from-foo-aliased ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ simple-from-foo
|
||||
[%simple-query from-foo [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ aliased-from-foo
|
||||
[%simple-query from-foo-aliased [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ joins-bar
|
||||
~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=~] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]]]
|
||||
++ from-foo-join-bar
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=joins-bar]]
|
||||
++ simple-from-foo-join-bar
|
||||
[%simple-query [~ [%priori from-foo-join-bar ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo-join-bar [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ joins-bar-aliased
|
||||
~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=[~ 'b1']] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]]]
|
||||
++ from-foo-join-bar-aliased
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=joins-bar-aliased]]
|
||||
++ simple-from-foo-join-bar-aliased
|
||||
[%simple-query [~ [%priori from-foo-join-bar-aliased ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo-join-bar-aliased [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ from-foo-aliased-join-bar-aliased
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=[~ 'f1']] joins=joins-bar-aliased]]
|
||||
++ aliased-from-foo-join-bar-aliased
|
||||
[%simple-query [~ [%priori from-foo-aliased-join-bar-aliased ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo-aliased-join-bar-aliased [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ joins-bar-baz
|
||||
~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=~] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]] [%joined-object join=%left-join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='baz'] alias=~] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]]]
|
||||
++ from-foo-join-bar-baz
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=joins-bar-baz]]
|
||||
++ simple-from-foo-join-bar-baz
|
||||
[%simple-query [~ [%priori from-foo-join-bar-baz ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo-join-bar-baz [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
++ aliased-joins-bar-baz
|
||||
~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=[~ 'B1']] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]] [%joined-object join=%left-join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='baz'] alias=[~ 'b2']] predicate=`[%eq [[value-type=%ud value=1] ~ ~] [[value-type=%ud value=1] ~ ~]]]]
|
||||
++ aliased-foo-join-bar-baz
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=[~ 'f1']] joins=aliased-joins-bar-baz]]
|
||||
++ aliased-from-foo-join-bar-baz
|
||||
[%simple-query [~ [%priori aliased-foo-join-bar-baz ~ ~]] [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query aliased-foo-join-bar-baz [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
::
|
||||
:: from foo (un-aliased)
|
||||
++ test-from-join-01
|
||||
@ -1083,63 +1083,63 @@
|
||||
++ test-predicate-01
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON T1.foo = T2.bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-02
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo<>bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%neq foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-03
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo!= bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%neq foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-04
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo >bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%gt foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-05
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo <bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%lt foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-06
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo>= bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%gte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-07
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo!< bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%gte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-08
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo <= bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%lte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
++ test-predicate-09
|
||||
=/ query "FROM adoptions AS T1 JOIN adoptions AS T2 ON foo !> bar SELECT *"
|
||||
=/ pred=(tree predicate-component:ast) [%lte foo bar]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] ~ ~]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
=/ expected=simple-query:ast [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`pred]]]] [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1152,7 +1152,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%between foobar-gte-foo foobar-lte-bar] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1163,7 +1163,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%between foobar-gte-foo foobar-lte-bar] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1174,7 +1174,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%between foobar-gte-foo foobar-lte-bar]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1185,7 +1185,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%between foobar-gte-foo foobar-lte-bar]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1196,7 +1196,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%gte t1-foo [%all bar ~]]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1207,7 +1207,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%in t1-foo bar] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1218,7 +1218,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%in t1-foo value-literal-list] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1229,7 +1229,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%in t1-foo bar]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1240,7 +1240,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%in t1-foo value-literal-list]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1251,7 +1251,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%exists t1-foo ~] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1262,7 +1262,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%not [%exists foo ~] ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1273,7 +1273,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%exists t1-foo ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1284,7 +1284,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) [%exists foo ~]
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1297,7 +1297,7 @@
|
||||
=/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ pred=(tree predicate-component:ast) and-fb-gte-f--fb-lte-b
|
||||
=/ expected=simple-query:ast
|
||||
[%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
[%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') query)
|
||||
@ -1311,7 +1311,7 @@
|
||||
:: =/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ pred=(tree predicate-component:ast) and-and
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1326,7 +1326,7 @@
|
||||
:: =/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ pred=(tree predicate-component:ast) and-and-or
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1343,7 +1343,7 @@
|
||||
:: =/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ pred=(tree predicate-component:ast) and-and-or-and
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1363,7 +1363,7 @@
|
||||
:: =/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ pred=(tree predicate-component:ast) and-and-or-and-or-and
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1381,7 +1381,7 @@
|
||||
:: =/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ pred=(tree predicate-component:ast) king-and
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1402,7 +1402,7 @@
|
||||
:: =/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ pred=(tree predicate-component:ast) a-a-l-a-o-l-a-a-r-o-r-a-l-o-r-a
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1421,7 +1421,7 @@
|
||||
:: =/ joinpred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ pred=(tree predicate-component:ast) king-and
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1466,7 +1466,7 @@
|
||||
:: =/ pred=(tree predicate-component:ast)
|
||||
:: [%and [%and [%and [%eq a1-adoption-email a2-adoption-email] [%eq a1-adoption-date a2-adoption-date]] [%eq foo bar]] [%or [%or [%and [%eq a1-name a2-name] [%gt a1-species a2-species]] [%and [%gt a1-name a2-name] [%eq a1-species a2-species]]] [%and [%gt a1-name a2-name] [%gt a1-species a2-species]]]]
|
||||
:: =/ expected=simple-query:ast
|
||||
:: [%simple-query [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] ~ `pred]] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: [%simple-query [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T1']] joins=~[[%joined-object join=%join object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='adoptions'] alias=[~ 'T2']] predicate=`joinpred]]]] [%group-by ~] [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]
|
||||
:: %+ expect-eq
|
||||
:: !> ~[expected]
|
||||
:: !> (parse:parse(current-database 'db1') query)
|
||||
@ -1597,112 +1597,112 @@
|
||||
++ test-select-01
|
||||
=/ select "select 0"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.n columns=~[[%selected-value [value-type=%ud value=0] ~]]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[[%selected-value [value-type=%ud value=0] ~]]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select top, bottom, distinct, trailing whitespace
|
||||
++ test-select-02
|
||||
=/ select "select top 10 bottom 10 distinct * "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select top, bottom, distinct
|
||||
++ test-select-03
|
||||
=/ select "select top 10 bottom 10 distinct *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select top bottom
|
||||
++ test-select-04
|
||||
=/ select "select top 10 bottom 10 *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select top, distinct, trailing whitespace
|
||||
++ test-select-05
|
||||
=/ select "select top 10 distinct * "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select top, distinct
|
||||
++ test-select-06
|
||||
=/ select "select top 10 distinct *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select top, trailing whitespace
|
||||
++ test-select-07
|
||||
=/ select "select top 10 * "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select top
|
||||
++ test-select-08
|
||||
=/ select "select top 10 *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select, trailing whitespace
|
||||
++ test-select-09
|
||||
=/ select "select * "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select
|
||||
++ test-select-10
|
||||
=/ select "select *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select bottom, distinct, trailing whitespace
|
||||
++ test-select-11
|
||||
=/ select "select bottom 10 distinct * "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select bottom, distinct
|
||||
++ test-select-12
|
||||
=/ select "select bottom 10 distinct *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select bottom, trailing whitespace
|
||||
++ test-select-13
|
||||
=/ select "select bottom 10 * "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select bottom
|
||||
++ test-select-14
|
||||
=/ select "select bottom 10 *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select distinct, trailing whitespace
|
||||
++ test-select-15
|
||||
=/ select "select distinct * "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: star select distinct
|
||||
++ test-select-16
|
||||
=/ select "select distinct *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: select top, bottom, distinct, simple columns
|
||||
@ -1711,58 +1711,58 @@
|
||||
" x1, db.ns.table.col1, table-alias.name, db..table.col2, T1.foo, 1, ~zod, 'cord'"
|
||||
=/ my-columns ~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='x1'] column='x1' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='ns' name='table'] column='col1' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='table-alias'] column='name' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='dbo' name='table'] column='col2' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='T1'] column='foo' alias=~] [%selected-value [value-type=%ud value=1] ~] [%selected-value [value-type=%p value=0] ~] [%selected-value [value-type=%t value='cord'] ~]]
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: from foo select top, bottom, distinct, simple columns, trailing space, no internal space
|
||||
++ test-select-18
|
||||
=/ select "from foo select top 10 bottom 10 distinct x1,db.ns.table.col1,table-alias.name,db..table.col2,T1.foo,1,~zod,'cord' "
|
||||
=/ from [~ [%priori [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=~]] ~ ~]]
|
||||
=/ from [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=~]]
|
||||
=/ my-columns ~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='x1'] column='x1' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='ns' name='table'] column='col1' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='table-alias'] column='name' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='dbo' name='table'] column='col2' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='T1'] column='foo' alias=~] [%selected-value [value-type=%ud value=1] ~] [%selected-value [value-type=%p value=0] ~] [%selected-value [value-type=%t value='cord'] ~]]
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query from [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~]]
|
||||
!> ~[[%simple-query from [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: aliased format 1 columns
|
||||
++ test-select-19
|
||||
=/ select "select x1 as foo , db.ns.table.col1 as foo2 , table-alias.name as bar , db..table.col2 as bar2 , 1 as foobar , ~zod as F1 , 'cord' as BAR3 "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.n columns=aliased-columns-1] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=aliased-columns-1] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: aliased format 1, top, bottom, distinct columns, no whitespace
|
||||
++ test-select-20
|
||||
=/ select "select top 10 bottom 10 distinct x1 as foo,db.ns.table.col1 as foo2,table-alias.name as bar,db..table.col2 as bar2,1 as foobar,~zod as F1,'cord' as BAR3"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aliased-columns-1] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aliased-columns-1] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: mixed all, object all, object alias all, column, aliased column
|
||||
++ test-select-21
|
||||
=/ select "select db..t1.* , foo as foobar , bar , * , T2.* "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.n columns=mixed-all] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=mixed-all] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: , top, bottom, distinct, mixed all, object all, object alias all, column, aliased column, no whitespace
|
||||
++ test-select-22
|
||||
=/ select "select top 10 bottom 10 distinct db..t1.*,foo as foobar,bar,*,T2.*"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=mixed-all] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=mixed-all] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: mixed aggregates
|
||||
++ test-select-23
|
||||
=/ select "select foo , COUNT(foo) as CountFoo, cOUNT( bar) ,sum(bar ) , sum( foobar ) as foobar "
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=~ bottom=~ distinct=%.n columns=aggregates] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=aggregates] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: , top, bottom, distinct, mixed aggregates, no whitespace
|
||||
++ test-select-24
|
||||
=/ select "select top 10 bottom 10 distinct foo,COUNT(foo) as CountFoo,cOUNT( bar),sum(bar ),sum( foobar ) as foobar"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aggregates] ~]]
|
||||
!> ~[[%simple-query ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aggregates] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: fail top, bottom, distinct, no bottom parameter, trailing whitespace
|
||||
@ -1910,16 +1910,16 @@
|
||||
!> group-by
|
||||
!> (wonk (parse-group-by:parse [[1 1] select]))
|
||||
::
|
||||
:: group by
|
||||
:: order by
|
||||
++ test-order-by-01
|
||||
=/ select "order by db.ns.table.col asc , T1.foo desc , 3 , 4 desc "
|
||||
%+ expect-eq
|
||||
!> order-by
|
||||
!> (wonk (parse-order-by:parse [[1 1] select]))
|
||||
::
|
||||
:: group by, no whitespace
|
||||
:: order by, no whitespace
|
||||
++ test-order-by-02
|
||||
=/ select "order by db.ns.table.col asc,T1.foo desc,3,4 desc"
|
||||
=/ select "order by db.ns.table.col aSc,T1.foo desc,3,4 Desc"
|
||||
%+ expect-eq
|
||||
!> order-by
|
||||
!> (wonk (parse-order-by:parse [[1 1] select]))
|
||||
|
@ -19,22 +19,26 @@ let outString (inString : string) =
|
||||
Replace("31.397.524.343.186.501.141.086.955.113", "%if-then-else").
|
||||
Replace("36.020.423.716.880.455.845.514.933.617", "%query-object").
|
||||
Replace("139.547.948.725.162.322.082.688.097", "%all-columns").
|
||||
Replace("121.413.839.493.834.722.620.239.461", "%end-command").
|
||||
Replace("1.871.507.249.111.214.024.545", "%aggregate").
|
||||
Replace("2.129.333.263.492.008.862.817", "'adoptions'").
|
||||
Replace("7.305.809.899.972.292.451", "%coalesce").
|
||||
Replace("8.746.603.387.336.749.671", "%group-by").
|
||||
Replace("8.386.668.330.298.337.636", "%distinct").
|
||||
Replace("7.305.809.899.972.292.451", "%coalesce").
|
||||
Replace("8.029.714.126.508.224.323", "CountFoo").
|
||||
Replace("32.481.125.635.289.203", "'species'").
|
||||
Replace("31.073.733.908.391.266", "%between").
|
||||
Replace("22.051.046.311.022.165", "'UNKNOWN'").
|
||||
Replace("120.325.462.585.186", "%bottom").
|
||||
Replace("127.970.252.186.995", "%select").
|
||||
Replace("125.762.588.864.358", "'foobar'").
|
||||
Replace("122.524.250.825.058", "'barfoo'").
|
||||
Replace("120.325.462.585.186", "%bottom").
|
||||
Replace("86.094.050.512.707", "'COLUMN'").
|
||||
Replace("500.069.396.323", "count").
|
||||
Replace("500.069.396.323", "'count'").
|
||||
Replace("439.854.853.733", "%endif").
|
||||
Replace("362.091.466.595", "cOUNT").
|
||||
Replace("362.091.466.563", "COUNT").
|
||||
Replace("435.610.083.700", "'table'").
|
||||
Replace("362.091.466.595", "'cOUNT'").
|
||||
Replace("362.091.466.563", "'COUNT'").
|
||||
Replace("211.446.545.203", "3;2;1").
|
||||
Replace("1.701.667.182", "'name'").
|
||||
Replace("1.852.403.562", "%join").
|
||||
@ -42,7 +46,7 @@ let outString (inString : string) =
|
||||
Replace("1.852.139.639", "%when").
|
||||
Replace("1.852.139.636", "%then").
|
||||
Replace("1.702.063.205", "%else").
|
||||
Replace("1.685.221.219", "cord").
|
||||
Replace("1.685.221.219", "'cord'").
|
||||
Replace("846.163.814", "'foo2'").
|
||||
Replace("846.356.834", "'bar2'").
|
||||
Replace("862.941.030", "'foo3'").
|
||||
@ -66,12 +70,14 @@ let outString (inString : string) =
|
||||
Replace("7.630.702", "%not").
|
||||
Replace("7.628.139", "%ket").
|
||||
Replace("7.299.684", "'dbo'").
|
||||
Replace("7.106.403", "'col'").
|
||||
Replace("6.648.940", "%lte").
|
||||
Replace("6.648.935", "%gte").
|
||||
Replace("6.581.861", "%end").
|
||||
Replace("3.236.452", "'db1'").
|
||||
Replace("29.799", "%gt").
|
||||
Replace("29.804", "%lt").
|
||||
Replace("29.550", "'ns'").
|
||||
Replace("29.537", "%as").
|
||||
Replace("29.295", "%or").
|
||||
Replace("28.265", "%in").
|
||||
|
Loading…
Reference in New Issue
Block a user