mirror of
https://github.com/jackfoxy/urQL.git
synced 2025-01-07 16:58:07 +03:00
no more select distinct
This commit is contained in:
parent
3dc8da62f9
commit
64881cc5c0
@ -127,5 +127,4 @@ Similarly `*` as the output of `DELETE`, `INSERT`, `MERGE` creates a pass-thru v
|
|||||||
10. Custom types and support for arbitrary noun columns - TBD
|
10. Custom types and support for arbitrary noun columns - TBD
|
||||||
11. Pivoting and windowing will be implemented in a future release.
|
11. Pivoting and windowing will be implemented in a future release.
|
||||||
12. `<view>` not implemented in parser and caching is TBD
|
12. `<view>` not implemented in parser and caching is TBD
|
||||||
13. `<cte-lib>` pre-built library of `<common-table-expression>`, TBD.
|
13. Option in `<merge>` to replicate `<target-table>`'s `<foreign-key>`s and/or unique indices when new `<table>` created.
|
||||||
14. Option in `<merge>` to replicate `<target-table>`'s `<foreign-key>`s and/or unique indices when new `<table>` created.
|
|
||||||
|
@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
```
|
```
|
||||||
<transform> ::=
|
<transform> ::=
|
||||||
[ WITH [ <common-table-expression> [ ,...n ] ]
|
[ WITH [ <common-table-expression> [ ,...n ] ] ]
|
||||||
[ <cte-lib> [ AS ] <alias> [ ,...n ] ]
|
|
||||||
]
|
|
||||||
<cmd>
|
<cmd>
|
||||||
[ INTO <table>
|
[ INTO <table>
|
||||||
| <set-op> [ ( ] <cmd> [ ) ]
|
| <set-op> [ ( ] <cmd> [ ) ]
|
||||||
|
@ -1550,14 +1550,6 @@
|
|||||||
(more com select-column)
|
(more com select-column)
|
||||||
select-column
|
select-column
|
||||||
==
|
==
|
||||||
++ select-top-bottom-distinct ;~ plug
|
|
||||||
(cold %top ;~(plug whitespace (jester 'top')))
|
|
||||||
;~(pfix whitespace dem)
|
|
||||||
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
|
||||||
;~(pfix whitespace dem)
|
|
||||||
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
|
||||||
select-columns
|
|
||||||
==
|
|
||||||
++ select-top-bottom ;~ plug
|
++ select-top-bottom ;~ plug
|
||||||
(cold %top ;~(plug whitespace (jester 'top')))
|
(cold %top ;~(plug whitespace (jester 'top')))
|
||||||
;~(pfix whitespace dem)
|
;~(pfix whitespace dem)
|
||||||
@ -1565,42 +1557,22 @@
|
|||||||
;~(pfix whitespace dem)
|
;~(pfix whitespace dem)
|
||||||
select-columns
|
select-columns
|
||||||
==
|
==
|
||||||
++ select-top-distinct ;~ plug
|
|
||||||
(cold %top ;~(plug whitespace (jester 'top')))
|
|
||||||
;~(pfix whitespace dem)
|
|
||||||
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
|
||||||
select-columns
|
|
||||||
==
|
|
||||||
++ select-top ;~ plug
|
++ select-top ;~ plug
|
||||||
(cold %top ;~(plug whitespace (jester 'top')))
|
(cold %top ;~(plug whitespace (jester 'top')))
|
||||||
;~(pfix whitespace dem)
|
;~(pfix whitespace dem)
|
||||||
;~(less ;~(plug whitespace (jester 'bottom')) select-columns)
|
;~(less ;~(plug whitespace (jester 'bottom')) select-columns)
|
||||||
==
|
==
|
||||||
++ select-bottom-distinct ;~ plug
|
|
||||||
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
|
||||||
;~(pfix whitespace dem)
|
|
||||||
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
|
||||||
select-columns
|
|
||||||
==
|
|
||||||
++ select-bottom ;~ plug
|
++ select-bottom ;~ plug
|
||||||
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
||||||
;~(pfix whitespace dem)
|
;~(pfix whitespace dem)
|
||||||
select-columns
|
select-columns
|
||||||
==
|
==
|
||||||
++ select-distinct ;~ plug
|
|
||||||
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
|
||||||
select-columns
|
|
||||||
==
|
|
||||||
++ parse-select ;~ plug
|
++ parse-select ;~ plug
|
||||||
(cold %select ;~(plug whitespace (jester 'select')))
|
(cold %select ;~(plug whitespace (jester 'select')))
|
||||||
;~ pose
|
;~ pose
|
||||||
select-top-bottom-distinct
|
|
||||||
select-top-bottom
|
select-top-bottom
|
||||||
select-top-distinct
|
|
||||||
select-top
|
select-top
|
||||||
select-bottom-distinct
|
|
||||||
select-bottom
|
select-bottom
|
||||||
select-distinct
|
|
||||||
select-columns
|
select-columns
|
||||||
==
|
==
|
||||||
==
|
==
|
||||||
@ -1706,18 +1678,16 @@
|
|||||||
^- select:ast
|
^- select:ast
|
||||||
=/ top=(unit @ud) ~
|
=/ top=(unit @ud) ~
|
||||||
=/ bottom=(unit @ud) ~
|
=/ bottom=(unit @ud) ~
|
||||||
=/ distinct=? %.n
|
|
||||||
=/ columns=(list selected-column:ast) ~
|
=/ columns=(list selected-column:ast) ~
|
||||||
|-
|
|-
|
||||||
~| "cannot parse select -.a: {<-.a>}"
|
~| "cannot parse select -.a: {<-.a>}"
|
||||||
?~ a
|
?~ a
|
||||||
?~ columns ~|('no columns selected' !!)
|
?~ columns ~|('no columns selected' !!)
|
||||||
(select:ast %select top bottom distinct (flop columns))
|
(select:ast %select top bottom (flop columns))
|
||||||
?@ -.a
|
?@ -.a
|
||||||
?+ -.a ~|('some other select atom' !!)
|
?+ -.a ~|('some other select atom' !!)
|
||||||
%top ?> ?=(@ud +<.a) $(top `+<.a, a +>.a)
|
%top ?> ?=(@ud +<.a) $(top `+<.a, a +>.a)
|
||||||
%bottom ?> ?=(@ud +<.a) $(bottom `+<.a, a +>.a)
|
%bottom ?> ?=(@ud +<.a) $(bottom `+<.a, a +>.a)
|
||||||
%distinct $(distinct %.y, a +.a)
|
|
||||||
%all
|
%all
|
||||||
%= $
|
%= $
|
||||||
columns [(qualified-object:ast %qualified-object ~ 'ALL' 'ALL' 'ALL') columns]
|
columns [(qualified-object:ast %qualified-object ~ 'ALL' 'ALL' 'ALL') columns]
|
||||||
|
@ -171,7 +171,6 @@
|
|||||||
%select
|
%select
|
||||||
top=(unit @ud)
|
top=(unit @ud)
|
||||||
bottom=(unit @ud)
|
bottom=(unit @ud)
|
||||||
distinct=?
|
|
||||||
columns=(list selected-column)
|
columns=(list selected-column)
|
||||||
==
|
==
|
||||||
+$ selected-column
|
+$ selected-column
|
||||||
|
@ -361,9 +361,9 @@
|
|||||||
++ cte-t1
|
++ cte-t1
|
||||||
[%cte name='t1' [%query ~ scalars=~ predicate=~ group-by=~ having=~ selection=select-all-columns ~]]
|
[%cte name='t1' [%query ~ scalars=~ predicate=~ group-by=~ having=~ selection=select-all-columns ~]]
|
||||||
++ cte-foobar
|
++ cte-foobar
|
||||||
[%cte name='foobar' [%query [~ [%from object=[%table-set object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foobar'] alias=~] joins=~]] scalars=~ `[%eq [col1 ~ ~] [[value-type=%ud value=2] ~ ~]] group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=~[col3 col4]] ~]]
|
[%cte name='foobar' [%query [~ [%from object=[%table-set object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foobar'] alias=~] joins=~]] scalars=~ `[%eq [col1 ~ ~] [[value-type=%ud value=2] ~ ~]] group-by=~ having=~ [%select top=~ bottom=~ columns=~[col3 col4]] ~]]
|
||||||
++ cte-bar
|
++ cte-bar
|
||||||
[%cte name='bar' [%query [~ [%from object=[%table-set object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=~] joins=~]] scalars=~ `[%eq [col1 ~ ~] [col2 ~ ~]] group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=~[col2]] ~]]
|
[%cte name='bar' [%query [~ [%from object=[%table-set object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=~] joins=~]] scalars=~ `[%eq [col1 ~ ~] [col2 ~ ~]] group-by=~ having=~ [%select top=~ bottom=~ columns=~[col2]] ~]]
|
||||||
++ foo-table
|
++ foo-table
|
||||||
[%qualified-object ship=~ database='db1' namespace='dbo' name='foo']
|
[%qualified-object ship=~ database='db1' namespace='dbo' name='foo']
|
||||||
::
|
::
|
||||||
@ -985,7 +985,7 @@
|
|||||||
::
|
::
|
||||||
:: from object and joins
|
:: from object and joins
|
||||||
::
|
::
|
||||||
++ select-top-10-all [%select top=[~ 10] bottom=~ distinct=%.y columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]]
|
++ select-top-10-all [%select top=[~ 10] bottom=~ columns=~[[%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']]]
|
||||||
++ from-foo
|
++ from-foo
|
||||||
[~ [%from object=[%table-set object=foo-table alias=~] joins=~]]
|
[~ [%from object=[%table-set object=foo-table alias=~] joins=~]]
|
||||||
++ from-foo-aliased
|
++ from-foo-aliased
|
||||||
@ -1078,109 +1078,109 @@
|
|||||||
++ test-from-join-01
|
++ test-from-join-01
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (aliased)
|
:: from foo (aliased)
|
||||||
++ test-from-join-02
|
++ test-from-join-02
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo] ~ ~]]]
|
!> ~[[%transform ctes=~ [[aliased-from-foo] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo F1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo F1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (aliased as)
|
:: from foo (aliased as)
|
||||||
++ test-from-join-03
|
++ test-from-join-03
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo] ~ ~]]]
|
!> ~[[%transform ctes=~ [[aliased-from-foo] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo as F1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo as F1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (un-aliased) join bar (un-aliased)
|
:: from foo (un-aliased) join bar (un-aliased)
|
||||||
++ test-from-join-04
|
++ test-from-join-04
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo join bar on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo join bar on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (un-aliased) join bar (aliased)
|
:: from foo (un-aliased) join bar (aliased)
|
||||||
++ test-from-join-05
|
++ test-from-join-05
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-aliased] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-aliased] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo join bar b1 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo join bar b1 on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (un-aliased) join bar (aliased as)
|
:: from foo (un-aliased) join bar (aliased as)
|
||||||
++ test-from-join-06
|
++ test-from-join-06
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-aliased] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-aliased] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo join bar as b1 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo join bar as b1 on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (aliased lower case) join bar (aliased as)
|
:: from foo (aliased lower case) join bar (aliased as)
|
||||||
++ test-from-join-07
|
++ test-from-join-07
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo-join-bar-aliased] ~ ~]]]
|
!> ~[[%transform ctes=~ [[aliased-from-foo-join-bar-aliased] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo f1 join bar b1 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo f1 join bar b1 on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (un-aliased) join bar (un-aliased) left join baz (un-aliased)
|
:: from foo (un-aliased) join bar (un-aliased) left join baz (un-aliased)
|
||||||
++ test-from-join-08
|
++ test-from-join-08
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-baz] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-baz] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo join bar on 1 = 1 left join baz on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo join bar on 1 = 1 left join baz on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (aliased) join bar (aliased) left join baz (aliased)
|
:: from foo (aliased) join bar (aliased) left join baz (aliased)
|
||||||
++ test-from-join-09
|
++ test-from-join-09
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo-join-bar-baz] ~ ~]]]
|
!> ~[[%transform ctes=~ [[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 *")
|
!> (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 *")
|
||||||
::
|
::
|
||||||
:: from pass-thru row (un-aliased)
|
:: from pass-thru row (un-aliased)
|
||||||
++ test-from-join-10
|
++ test-from-join-10
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-row] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-row] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM (col1, col2, col3) SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM (col1, col2, col3) SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from pass-thru row (aliased)
|
:: from pass-thru row (aliased)
|
||||||
++ test-from-join-11
|
++ test-from-join-11
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo-row] ~ ~]]]
|
!> ~[[%transform ctes=~ [[aliased-from-foo-row] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM (col1, col2, col3) F1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM (col1, col2, col3) F1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from pass-thru row (aliased as)
|
:: from pass-thru row (aliased as)
|
||||||
++ test-from-join-12
|
++ test-from-join-12
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo-row] ~ ~]]]
|
!> ~[[%transform ctes=~ [[aliased-from-foo-row] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM (col1, col2, col3) as F1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM (col1, col2, col3) as F1 SELECT TOP 10 *")
|
||||||
|
|
||||||
:: from foo (un-aliased) join pass-thru (un-aliased)
|
:: from foo (un-aliased) join pass-thru (un-aliased)
|
||||||
++ test-from-join-13
|
++ test-from-join-13
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo join (col1, col2, col3) on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo join (col1, col2, col3) on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (un-aliased) join pass-thru (aliased)
|
:: from foo (un-aliased) join pass-thru (aliased)
|
||||||
++ test-from-join-14
|
++ test-from-join-14
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row-aliased] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row-aliased] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo join (col1, col2, col3) b1 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo join (col1, col2, col3) b1 on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (un-aliased) join pass-thru (aliased as)
|
:: from foo (un-aliased) join pass-thru (aliased as)
|
||||||
++ test-from-join-15
|
++ test-from-join-15
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row-aliased] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row-aliased] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo join (col1,col2,col3) as b1 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo join (col1,col2,col3) as b1 on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo (aliased lower case) join pass-thru (aliased as)
|
:: from foo (aliased lower case) join pass-thru (aliased as)
|
||||||
++ test-from-join-16
|
++ test-from-join-16
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo-join-bar-row-aliased] ~ ~]]]
|
!> ~[[%transform ctes=~ [[aliased-from-foo-join-bar-row-aliased] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM foo f1 join (col1,col2,col3) b1 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM foo f1 join (col1,col2,col3) b1 on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from pass-thru (un-aliased) join bar (un-aliased) left join pass-thru (un-aliased)
|
:: from pass-thru (un-aliased) join bar (un-aliased) left join pass-thru (un-aliased)
|
||||||
++ test-from-join-17
|
++ test-from-join-17
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row-baz] ~ ~]]]
|
!> ~[[%transform ctes=~ [[simple-from-foo-join-bar-row-baz] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM (col1,col2,col3) join bar on 1 = 1 left join (col1,col2,col3) on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM (col1,col2,col3) join bar on 1 = 1 left join (col1,col2,col3) on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from pass-thru single column (aliased) join bar (aliased) left join pass-thru (aliased)
|
:: from pass-thru single column (aliased) join bar (aliased) left join pass-thru (aliased)
|
||||||
++ test-from-join-18
|
++ test-from-join-18
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[aliased-from-foo-join-bar-row-baz] ~ ~]]]
|
!> ~[[%transform ctes=~ [[aliased-from-foo-join-bar-row-baz] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') "FROM (col1) f1 join bar as B1 on 1 = 1 left join ( col1,col2,col3 ) b2 on 1 = 1 SELECT TOP 10 DISTINCT *")
|
!> (parse:parse(current-database 'db1') "FROM (col1) f1 join bar as B1 on 1 = 1 left join ( col1,col2,col3 ) b2 on 1 = 1 SELECT TOP 10 *")
|
||||||
::
|
::
|
||||||
:: from foo as (aliased) cross join bar (aliased)
|
:: from foo as (aliased) cross join bar (aliased)
|
||||||
++ test-from-join-19
|
++ test-from-join-19
|
||||||
@ -1276,7 +1276,7 @@
|
|||||||
::
|
::
|
||||||
:: re-used components
|
:: re-used components
|
||||||
++ all-columns [%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']
|
++ all-columns [%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']
|
||||||
++ select-all-columns [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]]
|
++ select-all-columns [%select top=~ bottom=~ columns=~[all-columns]]
|
||||||
++ foo
|
++ foo
|
||||||
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo'] 'foo' ~] ~ ~]
|
[[%qualified-column [%qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' 'foo'] 'foo' ~] ~ ~]
|
||||||
++ t1-foo
|
++ t1-foo
|
||||||
@ -1432,10 +1432,10 @@
|
|||||||
!> ~[expected]
|
!> ~[expected]
|
||||||
!> (parse:parse(current-database 'db1') query)
|
!> (parse:parse(current-database 'db1') query)
|
||||||
++ test-predicate-10
|
++ test-predicate-10
|
||||||
=/ query "FROM foo WHERE foobar EQUIV bar SELECT DISTINCT *"
|
=/ query "FROM foo WHERE foobar EQUIV bar SELECT *"
|
||||||
=/ pred=(tree predicate-component:ast) [%equiv foobar bar]
|
=/ pred=(tree predicate-component:ast) [%equiv foobar bar]
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query from-foo scalars=~ `pred group-by=~ having=~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~]] ~ ~]]
|
!> ~[[%transform ctes=~ [[%query from-foo scalars=~ `pred group-by=~ having=~ [%select top=~ bottom=~ columns=~[all-columns]] ~]] ~ ~]]
|
||||||
!> (parse:parse(current-database 'db1') query)
|
!> (parse:parse(current-database 'db1') query)
|
||||||
++ test-predicate-11
|
++ test-predicate-11
|
||||||
=/ query "FROM foo WHERE foobar NOT EQUIV bar SELECT *"
|
=/ query "FROM foo WHERE foobar NOT EQUIV bar SELECT *"
|
||||||
@ -1910,56 +1910,56 @@
|
|||||||
++ test-select-01
|
++ test-select-01
|
||||||
=/ select "select 0"
|
=/ select "select 0"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=~[[%selected-value [value-type=%ud value=0] ~]]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ columns=~[[%selected-value [value-type=%ud value=0] ~]]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select top, bottom, distinct, trailing whitespace
|
:: star select top, bottom, trailing whitespace
|
||||||
++ test-select-02
|
++ test-select-02
|
||||||
=/ select "select top 10 bottom 10 distinct * "
|
=/ select "select top 10 bottom 10 * "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select top, bottom, distinct
|
:: star select top, bottom
|
||||||
++ test-select-03
|
++ test-select-03
|
||||||
=/ select "select top 10 bottom 10 distinct *"
|
=/ select "select top 10 bottom 10 *"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select top bottom
|
:: star select top bottom
|
||||||
++ test-select-04
|
++ test-select-04
|
||||||
=/ select "select top 10 bottom 10 *"
|
=/ select "select top 10 bottom 10 *"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select top, distinct, trailing whitespace
|
:: star select top, trailing whitespace
|
||||||
++ test-select-05
|
++ test-select-05
|
||||||
=/ select "select top 10 distinct * "
|
=/ select "select top 10 * "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select top, distinct
|
:: star select top
|
||||||
++ test-select-06
|
++ test-select-06
|
||||||
=/ select "select top 10 distinct *"
|
=/ select "select top 10 *"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select top, trailing whitespace
|
:: star select top, trailing whitespace
|
||||||
++ test-select-07
|
++ test-select-07
|
||||||
=/ select "select top 10 * "
|
=/ select "select top 10 * "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select top
|
:: star select top
|
||||||
++ test-select-08
|
++ test-select-08
|
||||||
=/ select "select top 10 *"
|
=/ select "select top 10 *"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ distinct=%.n columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=~ columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select, trailing whitespace
|
:: star select, trailing whitespace
|
||||||
@ -1976,129 +1976,129 @@
|
|||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ select-all-columns ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ select-all-columns ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select bottom, distinct, trailing whitespace
|
:: star select bottom, trailing whitespace
|
||||||
++ test-select-11
|
++ test-select-11
|
||||||
=/ select "select bottom 10 distinct * "
|
=/ select "select bottom 10 * "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select bottom, distinct
|
:: star select bottom
|
||||||
++ test-select-12
|
++ test-select-12
|
||||||
=/ select "select bottom 10 distinct *"
|
=/ select "select bottom 10 *"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select bottom, trailing whitespace
|
:: star select bottom, trailing whitespace
|
||||||
++ test-select-13
|
++ test-select-13
|
||||||
=/ select "select bottom 10 * "
|
=/ select "select bottom 10 * "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select bottom
|
:: star select bottom
|
||||||
++ test-select-14
|
++ test-select-14
|
||||||
=/ select "select bottom 10 *"
|
=/ select "select bottom 10 *"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] distinct=%.n columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=[~ 10] columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select distinct, trailing whitespace
|
:: star select, trailing whitespace
|
||||||
++ test-select-15
|
++ test-select-15
|
||||||
=/ select "select distinct * "
|
=/ select "select * "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: star select distinct
|
:: star select
|
||||||
++ test-select-16
|
++ test-select-16
|
||||||
=/ select "select distinct *"
|
=/ select "select *"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ distinct=%.y columns=~[all-columns]] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ columns=~[all-columns]] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: select top, bottom, distinct, simple columns
|
:: select top, bottom, simple columns
|
||||||
++ test-select-17
|
++ test-select-17
|
||||||
=/ select "select top 10 bottom 10 distinct ".
|
=/ select "select top 10 bottom 10 ".
|
||||||
" x1, db.ns.table.col1, table-alias.name, db..table.col2, T1.foo, 1, ~zod, 'cord'"
|
" 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 literal-1 ~] [%selected-value [value-type=%p value=0] ~] [%selected-value [value-type=%t value='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 literal-1 ~] [%selected-value [value-type=%p value=0] ~] [%selected-value [value-type=%t value='cord'] ~]]
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=my-columns] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: from foo select top, bottom, distinct, simple columns, trailing space, no internal space
|
:: from foo select top, bottom, simple columns, trailing space, no internal space
|
||||||
++ test-select-18
|
++ 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' "
|
=/ select "from foo select top 10 bottom 10 x1,db.ns.table.col1,table-alias.name,db..table.col2,T1.foo,1,~zod,'cord' "
|
||||||
=/ from [~ [%from object=[%table-set object=foo-table alias=~] joins=~]]
|
=/ from [~ [%from object=[%table-set object=foo-table 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 literal-1 ~] [%selected-value [value-type=%p value=0] ~] [%selected-value [value-type=%t value='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 literal-1 ~] [%selected-value [value-type=%p value=0] ~] [%selected-value [value-type=%t value='cord'] ~]]
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query from scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=my-columns] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query from scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=my-columns] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: aliased format 1 columns
|
:: aliased format 1 columns
|
||||||
++ test-select-19
|
++ 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 "
|
=/ 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
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=aliased-columns-1] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ columns=aliased-columns-1] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: aliased format 1, top, bottom, distinct columns, no whitespace
|
:: aliased format 1, top, bottom columns, no whitespace
|
||||||
++ test-select-20
|
++ 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"
|
=/ select "select top 10 bottom 10 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
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aliased-columns-1] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=aliased-columns-1] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: mixed all, object all, object alias all, column, aliased column
|
:: mixed all, object all, object alias all, column, aliased column
|
||||||
++ test-select-21
|
++ test-select-21
|
||||||
=/ select "select db..t1.* , foo as foobar , bar , * , T2.* "
|
=/ select "select db..t1.* , foo as foobar , bar , * , T2.* "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=mixed-all] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ columns=mixed-all] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: , top, bottom, distinct, mixed all, object all, object alias all, column, aliased column, no whitespace
|
:: , top, bottom, mixed all, object all, object alias all, column, aliased column, no whitespace
|
||||||
++ test-select-22
|
++ test-select-22
|
||||||
=/ select "select top 10 bottom 10 distinct db..t1.*,foo as foobar,bar,*,T2.*"
|
=/ select "select top 10 bottom 10 db..t1.*,foo as foobar,bar,*,T2.*"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=mixed-all] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=mixed-all] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: mixed aggregates
|
:: mixed aggregates
|
||||||
++ test-select-23
|
++ test-select-23
|
||||||
=/ select "select foo , COUNT(foo) as CountFoo, cOUNT( bar) ,sum(bar ) , sum( foobar ) as foobar "
|
=/ select "select foo , COUNT(foo) as CountFoo, cOUNT( bar) ,sum(bar ) , sum( foobar ) as foobar "
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=aggregates] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=~ bottom=~ columns=aggregates] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: , top, bottom, distinct, mixed aggregates, no whitespace
|
:: , top, bottom, mixed aggregates, no whitespace
|
||||||
++ test-select-24
|
++ test-select-24
|
||||||
=/ select "select top 10 bottom 10 distinct foo,COUNT(foo) as CountFoo,cOUNT( bar),sum(bar ),sum( foobar ) as foobar"
|
=/ select "select top 10 bottom 10 foo,COUNT(foo) as CountFoo,cOUNT( bar),sum(bar ),sum( foobar ) as foobar"
|
||||||
%+ expect-eq
|
%+ expect-eq
|
||||||
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] distinct=%.y columns=aggregates] ~] ~ ~]]]
|
!> ~[[%transform ctes=~ [[%query ~ scalars=~ ~ group-by=~ having=~ [%select top=[~ 10] bottom=[~ 10] columns=aggregates] ~] ~ ~]]]
|
||||||
!> (parse:parse(current-database 'db1') select)
|
!> (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, bottom, distinct, no bottom parameter, trailing whitespace
|
:: fail top, bottom, no bottom parameter, trailing whitespace
|
||||||
++ test-fail-select-25
|
++ test-fail-select-25
|
||||||
=/ select "select top 10 bottom distinct * "
|
=/ select "select top 10 bottom * "
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, bottom, distinct, no bottom parameter
|
:: fail top, bottom, no bottom parameter
|
||||||
++ test-fail-select-26
|
++ test-fail-select-26
|
||||||
=/ select "select top 10 bottom distinct *"
|
=/ select "select top 10 bottom *"
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, bottom, distinct, no top parameter, trailing whitespace
|
:: fail top, bottom, no top parameter, trailing whitespace
|
||||||
++ test-fail-select-27
|
++ test-fail-select-27
|
||||||
=/ select "select top bottom 10 distinct * "
|
=/ select "select top bottom 10 * "
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, bottom, distinct, no top parameter
|
:: fail top, bottom, no top parameter
|
||||||
++ test-fail-select-28
|
++ test-fail-select-28
|
||||||
=/ select "select top bottom 10 distinct *"
|
=/ select "select top bottom 10 *"
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
@ -2126,15 +2126,15 @@
|
|||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, distinct, no top parameter, trailing whitespace
|
:: fail top, no top parameter, trailing whitespace
|
||||||
++ test-fail-select-33
|
++ test-fail-select-33
|
||||||
=/ select "select top distinct * "
|
=/ select "select top * "
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, distinct, no top parameter
|
:: fail top, no top parameter
|
||||||
++ test-fail-select-34
|
++ test-fail-select-34
|
||||||
=/ select "select top distinct *"
|
=/ select "select top *"
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
@ -2144,15 +2144,15 @@
|
|||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail bottom, distinct, no bottom parameter, trailing whitespace
|
:: fail bottom, no bottom parameter, trailing whitespace
|
||||||
++ test-fail-select-36
|
++ test-fail-select-36
|
||||||
=/ select "select bottom distinct * "
|
=/ select "select bottom * "
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail bottom, distinct, no bottom parameter
|
:: fail bottom, no bottom parameter
|
||||||
++ test-fail-select-37
|
++ test-fail-select-37
|
||||||
=/ select "select bottom distinct *"
|
=/ select "select bottom *"
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
@ -2162,9 +2162,9 @@
|
|||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, bottom, distinct, no column selection
|
:: fail top, bottom, no column selection
|
||||||
++ test-fail-select-39
|
++ test-fail-select-39
|
||||||
=/ select "select top 10 bottom 10 distinct"
|
=/ select "select top 10 bottom 10"
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
@ -2180,9 +2180,9 @@
|
|||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail top, distinct, no column selection
|
:: fail top, no column selection
|
||||||
++ test-fail-select-42
|
++ test-fail-select-42
|
||||||
=/ select "select top 10 distinct"
|
=/ select "select top 10"
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
@ -2192,9 +2192,9 @@
|
|||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
:: fail bottom, distinct, no column selection
|
:: fail bottom, no column selection
|
||||||
++ test-fail-select-44
|
++ test-fail-select-44
|
||||||
=/ select "select bottom 10 distinct"
|
=/ select "select bottom 10"
|
||||||
%- expect-fail
|
%- expect-fail
|
||||||
|. (parse:parse(current-database 'db1') select)
|
|. (parse:parse(current-database 'db1') select)
|
||||||
::
|
::
|
||||||
@ -2286,9 +2286,9 @@
|
|||||||
++ predicate-bar-eq-bar
|
++ predicate-bar-eq-bar
|
||||||
[%eq [[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='tgt'] column='bar' alias=~] ~ ~] [[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='bar' alias=~] ~ ~]]
|
[%eq [[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='tgt'] column='bar' alias=~] ~ ~] [[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='bar' alias=~] ~ ~]]
|
||||||
++ cte-bar-foobar
|
++ cte-bar-foobar
|
||||||
[%cte name='T1' %query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ distinct=%.n columns=~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='bar'] column='bar' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='foobar'] column='foobar' alias=~]]] order-by=~]
|
[%cte name='T1' %query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='bar'] column='bar' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='foobar'] column='foobar' alias=~]]] order-by=~]
|
||||||
++ cte-bar-foobar-src
|
++ cte-bar-foobar-src
|
||||||
[%cte name='src' %query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ distinct=%.n columns=~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='bar'] column='bar' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='foobar'] column='foobar' alias=~]]] order-by=~]
|
[%cte name='src' %query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ columns=~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='bar'] column='bar' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='foobar'] column='foobar' alias=~]]] order-by=~]
|
||||||
++ column-src-foo
|
++ column-src-foo
|
||||||
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='foo' alias=~]
|
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='foo' alias=~]
|
||||||
++ column-src-bar
|
++ column-src-bar
|
||||||
|
Loading…
Reference in New Issue
Block a user