mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-09-11 11:55:33 +03:00
group-by broken, accomodate having
This commit is contained in:
parent
1af10b6132
commit
3db0bb8c6c
@ -59,6 +59,7 @@
|
||||
+$ raw-predicate-component ?(parens predicate-component:ast predicate:ast)
|
||||
+$ raw-predicate-component2 ?(parens predicate-component:ast)
|
||||
+$ group-by-list (list grouping-column:ast)
|
||||
+$ order-by-list (list ordering-column:ast)
|
||||
::
|
||||
:: get next position in script
|
||||
::
|
||||
@ -1090,6 +1091,7 @@
|
||||
=/ bottom=(unit @ud) ~
|
||||
=/ distinct=? %.n
|
||||
=/ columns=(list selected-column:ast) ~
|
||||
:: ?@ a $(a [a ~])
|
||||
|-
|
||||
~| "cannot parse select -.a: {<-.a>}"
|
||||
?~ a
|
||||
@ -1149,20 +1151,23 @@
|
||||
=/ from=(unit from:ast) ~
|
||||
=/ scalars=(list scalar-function:ast) ~
|
||||
=/ predicate=(unit predicate:ast) ~
|
||||
=/ select=(unit select:ast) ~
|
||||
=/ group-by=(list grouping-column:ast) ~
|
||||
=/ order-by=(unit order-by:ast) ~
|
||||
=/ having=(unit predicate:ast) ~
|
||||
=/ select=(unit select:ast) ~
|
||||
|
||||
=/ order-by=(list ordering-column:ast) ~
|
||||
|-
|
||||
:: ~| "a: {<a>}"
|
||||
?~ a ~|("cannot parse simple-query {<a>}" !!)
|
||||
?: =(i.a %query) $(a t.a)
|
||||
?: =(i.a %end-command)
|
||||
(simple-query:ast %simple-query from [%group-by group-by] [%scalars scalars] predicate (need select) order-by)
|
||||
(simple-query:ast %simple-query from [%scalars scalars] predicate [%group-by group-by] [%having having] (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 (group-by-list ->.a))
|
||||
?: =(-<.a %order-by) $(a t.a, order-by ~)
|
||||
?: =(-<.a %order-by) $(a t.a, order-by (order-by-list ->.a))
|
||||
?: =(-<-.a %query-object) $(a t.a, from `(produce-from i.a))
|
||||
~|("cannot parse simple-query {<a>}" !!)
|
||||
::
|
||||
@ -1239,11 +1244,11 @@
|
||||
==
|
||||
++ 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-group-by
|
||||
parse-select
|
||||
:: parse-order-by
|
||||
parse-order-by
|
||||
end-or-next-command
|
||||
==
|
||||
++ parse-query2 ;~ plug
|
||||
@ -1256,14 +1261,21 @@
|
||||
==
|
||||
++ 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
|
||||
:: (stag %scalars (star parse-scalar))
|
||||
parse-group-by
|
||||
parse-select
|
||||
|
||||
:: parse-order-by
|
||||
end-or-next-command
|
||||
==
|
||||
++ parse-query4 ;~ plug
|
||||
++ parse-query5 ;~ plug
|
||||
parse-object-and-joins
|
||||
parse-select
|
||||
end-or-next-command
|
||||
@ -1277,6 +1289,7 @@
|
||||
parse-query2
|
||||
parse-query3
|
||||
parse-query4
|
||||
parse-query5
|
||||
parse-query9
|
||||
==
|
||||
++ parse-revoke ;~ plug
|
||||
|
@ -126,11 +126,12 @@
|
||||
$:
|
||||
%simple-query
|
||||
(unit from)
|
||||
[%group-by (list grouping-column)]
|
||||
[%scalars (list scalar-function)]
|
||||
(unit predicate)
|
||||
[%group-by (list grouping-column)]
|
||||
[%having (unit predicate)]
|
||||
select
|
||||
(unit order-by)
|
||||
(list ordering-column)
|
||||
==
|
||||
+$ from
|
||||
$:
|
||||
@ -194,7 +195,6 @@
|
||||
grouping-column
|
||||
is-ascending=?
|
||||
==
|
||||
+$ order-by (list ordering-column)
|
||||
+$ cte-query
|
||||
$:
|
||||
%cte
|
||||
|
@ -16,27 +16,45 @@
|
||||
::
|
||||
:: -test /=urql=/tests/lib/parse/hoon ~
|
||||
|%
|
||||
:: re-used components
|
||||
++ all-columns [%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']
|
||||
++ group-by [%group-by ~[[%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='ns' name='table'] column='col' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='T1'] column='foo' alias=~] 3 4]]
|
||||
++ order-by [%order-by ~[[%ordering-column [%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='ns' name='table'] column='col' alias=~] is-ascending=%.y] [%ordering-column [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='T1'] column='foo' alias=~] is-ascending=%.n] [%ordering-column 3 is-ascending=%.y] [%ordering-column 4 is-ascending=%.n]]]
|
||||
++ from-foo [~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=~]]
|
||||
++ t1-foo
|
||||
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'T1'] 'foo' ~] ~ ~]
|
||||
++ t2-bar
|
||||
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN' 'T2'] 'bar' ~] ~ ~]
|
||||
++ from-foo
|
||||
[~ [%from object=[%query-object object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foo'] alias=~] joins=~]]
|
||||
++ all-columns [%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']
|
||||
::
|
||||
:: group and order by
|
||||
::
|
||||
++ group-by [%group-by ~[[%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='ns' name='table'] column='col' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='T1'] column='foo' alias=~] 3 4]]
|
||||
++ order-by [%order-by ~[[%ordering-column [%qualified-column qualifier=[%qualified-object ship=~ database='db' namespace='ns' name='table'] column='col' alias=~] is-ascending=%.y] [%ordering-column [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='T1'] column='foo' alias=~] is-ascending=%.n] [%ordering-column 3 is-ascending=%.y] [%ordering-column 4 is-ascending=%.n]]]
|
||||
::
|
||||
:: group by
|
||||
++ test-group-by-01
|
||||
=/ select "from foo group by db.ns.table.col , T1.foo , 3 , 4 select *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query from-foo group-by [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query from-foo [%scalars ~] ~ group-by [%having ~] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
|
||||
::
|
||||
:: group by, no whitespace, with predicate
|
||||
++ test-group-by-02
|
||||
=/ pred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ select "from foo group by db.ns.table.col,T1.foo,3,4 where T1.foo = T2.bar select *"
|
||||
=/ select "from foo where T1.foo = T2.bar group by db.ns.table.col,T1.foo,3,4 select *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query from-foo group-by [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query from-foo [%scalars ~] `pred group-by [%having ~] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: order by
|
||||
::++ test-order-by-01
|
||||
:: =/ select "from foo select * order by db.ns.table.col asc , T1.foo desc , 3 , 4 desc "
|
||||
:: %+ expect-eq
|
||||
:: !> order-by
|
||||
:: !> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: order by, no whitespace
|
||||
::++ test-order-by-02
|
||||
:: =/ 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]))
|
||||
--
|
@ -921,37 +921,37 @@
|
||||
++ 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 from-foo [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo [%scalars ~] ~ [%group-by ~] [%having ~] [%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']]] ~]
|
||||
[%simple-query from-foo-aliased [%scalars ~] ~ [%group-by ~] [%having ~] [%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 from-foo-join-bar [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo-join-bar [%scalars ~] ~ [%group-by ~] [%having ~] [%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 from-foo-join-bar-aliased [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo-join-bar-aliased [%scalars ~] ~ [%group-by ~] [%having ~] [%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 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']]] ~]
|
||||
[%simple-query from-foo-aliased-join-bar-aliased [%scalars ~] ~ [%group-by ~] [%having ~] [%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 from-foo-join-bar-baz [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query from-foo-join-bar-baz [%scalars ~] ~ [%group-by ~] [%having ~] [%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 aliased-foo-join-bar-baz [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]] ~]
|
||||
[%simple-query aliased-foo-join-bar-baz [%scalars ~] ~ [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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]] ~]
|
||||
=/ 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]]]] [%scalars ~] ~ [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
[%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 [~ [%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]] ~]
|
||||
:: [%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]]]] [%scalars ~] `pred [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[[%selected-value [value-type=%ud value=0] ~]]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: select top, bottom, distinct, simple columns
|
||||
@ -1711,7 +1711,7 @@
|
||||
" 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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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
|
||||
@ -1720,49 +1720,49 @@
|
||||
=/ 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 [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~]]
|
||||
!> ~[[%simple-query from [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=aliased-columns-1] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aliased-columns-1] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=mixed-all] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=mixed-all] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=aggregates] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%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 ~ [%group-by ~] [%scalars ~] ~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aggregates] ~]]
|
||||
!> ~[[%simple-query ~ [%scalars ~] ~ [%group-by ~] [%having ~] [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aggregates] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: fail top, bottom, distinct, no bottom parameter, trailing whitespace
|
||||
@ -1900,28 +1900,28 @@
|
||||
++ test-group-by-01
|
||||
=/ select "from foo group by db.ns.table.col , T1.foo , 3 , 4 select *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query from-foo group-by [%scalars ~] ~ [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> ~[[%simple-query from-foo [%scalars ~] ~ group-by [%having ~] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: group by, no whitespace, with predicate
|
||||
++ test-group-by-02
|
||||
=/ pred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
=/ select "from foo group by db.ns.table.col,T1.foo,3,4 where T1.foo = T2.bar select *"
|
||||
%+ expect-eq
|
||||
!> ~[[%simple-query from-foo group-by [%scalars ~] `pred [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
!> (parse:parse(current-database 'db1') select)
|
||||
::++ test-group-by-02
|
||||
:: =/ pred=(tree predicate-component:ast) [%eq t1-foo t2-bar]
|
||||
:: =/ select "from foo where T1.foo = T2.bar group by db.ns.table.col,T1.foo,3,4 select *"
|
||||
:: %+ expect-eq
|
||||
:: !> ~[[%simple-query from-foo [%scalars ~] `pred group-by [%having ~] [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]] ~]]
|
||||
:: !> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: 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]))
|
||||
::++ test-order-by-01
|
||||
:: =/ select "from foo select * order by db.ns.table.col asc , T1.foo desc , 3 , 4 desc "
|
||||
:: %+ expect-eq
|
||||
:: !> order-by
|
||||
:: !> (parse:parse(current-database 'db1') select)
|
||||
::
|
||||
:: order by, no whitespace
|
||||
++ test-order-by-02
|
||||
=/ 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]))
|
||||
::++ test-order-by-02
|
||||
:: =/ 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]))
|
||||
--
|
Loading…
Reference in New Issue
Block a user