mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-08-16 15:20:48 +03:00
db & ns create as of
This commit is contained in:
parent
462c4e7ab9
commit
fcb65bf81d
@ -4,6 +4,31 @@
|
||||
:: (parse:parse(default-database '<db>') "<script>")
|
||||
|_ default-database=@tas
|
||||
::
|
||||
:: +when: replace when:so until https://github.com/urbit/urbit/issues/6870
|
||||
++ when ~+
|
||||
;~ plug
|
||||
%+ cook
|
||||
|=([a=@ b=?] [b a])
|
||||
;~(plug dim:ag ;~(pose (cold | hep) (easy &)))
|
||||
;~(pfix dot mot:ag) :: month
|
||||
;~(pfix dot dip:ag) :: day
|
||||
;~ pose
|
||||
;~ pfix
|
||||
;~(plug dot dot)
|
||||
;~ plug
|
||||
dum:ag
|
||||
;~(pfix dot dum:ag)
|
||||
;~(pfix dot dum:ag)
|
||||
;~ pose
|
||||
;~(pfix ;~(plug dot dot) (most dot qix:ab))
|
||||
;~(less dot (easy ~))
|
||||
==
|
||||
==
|
||||
==
|
||||
;~(less dot (easy [0 0 0 ~]))
|
||||
==
|
||||
==
|
||||
::
|
||||
:: +clip-cmnt: clip commented end of line
|
||||
::
|
||||
++ clip-cmnt
|
||||
@ -204,14 +229,36 @@
|
||||
==
|
||||
~|("Cannot parse table {<p.q.command-nail>}" !!)
|
||||
%create-database
|
||||
~| "create database error: {<(scag 40 q.q.command-nail)>} ..."
|
||||
~| 'Create database must be only statement in script'
|
||||
~| "Create database error: {<(scag 40 q.q.command-nail)>} ..."
|
||||
?> =((lent commands) 0)
|
||||
%= $
|
||||
script ""
|
||||
commands
|
||||
[`command:ast`(create-database:ast %create-database p.u.+3:q.+3:(parse-face [[1 1] q.q.command-nail]) ~) commands]
|
||||
==
|
||||
=/ nail (parse-create-database [[1 1] q.q.command-nail])
|
||||
=/ parsed (wonk nail)
|
||||
?@ parsed
|
||||
%= $
|
||||
script ""
|
||||
commands
|
||||
[`command:ast`(create-database:ast %create-database parsed ~) commands]
|
||||
==
|
||||
?: =(%now +>.parsed)
|
||||
%= $
|
||||
script ""
|
||||
commands
|
||||
[`command:ast`(create-database:ast %create-database -.parsed ~) commands]
|
||||
==
|
||||
?: ?=([@ @] +>.parsed)
|
||||
%= $
|
||||
script ""
|
||||
commands
|
||||
[`command:ast`(create-database:ast %create-database -.parsed [~ `@da`+>+.parsed]) commands]
|
||||
==
|
||||
?: ?=([@ @ @] +>.parsed)
|
||||
%= $
|
||||
script ""
|
||||
commands
|
||||
[`command:ast`(create-database:ast %create-database -.parsed [~ (as-of-offset:ast %as-of-offset +>-.parsed +>+<.parsed)]) commands]
|
||||
==
|
||||
!!
|
||||
%create-index
|
||||
~| "create index error: {<(scag 100 q.q.command-nail)>} ..."
|
||||
=/ index-nail (parse-create-index [[1 1] q.q.command-nail])
|
||||
@ -268,15 +315,41 @@
|
||||
=/ create-namespace-nail (parse-create-namespace [[1 1] q.q.command-nail])
|
||||
=/ parsed (wonk create-namespace-nail)
|
||||
?@ parsed
|
||||
%= $
|
||||
script q.q.u.+3.q:create-namespace-nail
|
||||
displacement (sub script-length (lent script))
|
||||
commands [`command:ast`(create-namespace:ast %create-namespace default-database parsed ~) commands]
|
||||
==
|
||||
?: ?=([@ @] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:create-namespace-nail
|
||||
displacement (sub script-length (lent script))
|
||||
commands [`command:ast`(create-namespace:ast %create-namespace default-database parsed ~) commands]
|
||||
displacement (sub script-length (lent script))
|
||||
commands [`command:ast`(create-namespace:ast %create-namespace -.parsed +.parsed ~) commands]
|
||||
==
|
||||
=/ id -.parsed
|
||||
=/ asof +>.parsed
|
||||
?: =(%now asof)
|
||||
%= $
|
||||
script q.q.u.+3.q:create-namespace-nail
|
||||
displacement (sub script-length (lent script))
|
||||
commands ?@ id
|
||||
[`command:ast`(create-namespace:ast %create-namespace default-database id ~) commands]
|
||||
[`command:ast`(create-namespace:ast %create-namespace -.id +.id ~) commands]
|
||||
==
|
||||
?: ?=([@ @] asof)
|
||||
%= $
|
||||
script q.q.u.+3.q:create-namespace-nail
|
||||
displacement (sub script-length (lent script))
|
||||
commands ?@ id
|
||||
[`command:ast`(create-namespace:ast %create-namespace default-database id [~ `@da`+.asof]) commands]
|
||||
[`command:ast`(create-namespace:ast %create-namespace -.id +.id [~ `@da`+.asof]) commands]
|
||||
==
|
||||
%= $
|
||||
script q.q.u.+3.q:create-namespace-nail
|
||||
displacement (sub script-length (lent script))
|
||||
commands [`command:ast`(create-namespace:ast %create-namespace -.parsed +.parsed ~) commands]
|
||||
script q.q.u.+3.q:create-namespace-nail
|
||||
displacement (sub script-length (lent script))
|
||||
commands ?@ id
|
||||
[`command:ast`(create-namespace:ast %create-namespace default-database id [~ (as-of-offset:ast %as-of-offset -.asof +<.asof)]) commands]
|
||||
[`command:ast`(create-namespace:ast %create-namespace -.id +.id [~ (as-of-offset:ast %as-of-offset -.asof +<.asof)]) commands]
|
||||
==
|
||||
%create-table
|
||||
~| "create table error: {<(scag 100 q.q.command-nail)>} ..."
|
||||
@ -295,6 +368,12 @@
|
||||
commands
|
||||
[`command:ast`(create-table:ast %create-table -.parsed +<.parsed +>->-.parsed +>->+.parsed (build-foreign-keys [-.parsed +>+.parsed]) ~) commands]
|
||||
==
|
||||
|
||||
:: ~| "parsed: {<parsed>}"
|
||||
:: ~| "id: {<id>}"
|
||||
:: ~| "as-of: {<asof>}"
|
||||
|
||||
|
||||
%create-view
|
||||
~| "create view error: {<(scag 100 q.q.command-nail)>} ..."
|
||||
!!
|
||||
@ -599,8 +678,16 @@
|
||||
;~(pfix whitespace parse-qualified-3object)
|
||||
;~(sfix ;~(pfix whitespace ;~(pose alter-columns add-columns drop-columns add-foreign-key drop-foreign-key)) end-or-next-command)
|
||||
==
|
||||
++ parse-create-database
|
||||
;~ pose
|
||||
;~(plug parse-face parse-as-of)
|
||||
parse-face
|
||||
==
|
||||
++ parse-create-namespace ;~ sfix
|
||||
parse-qualified-2-name
|
||||
;~ pose
|
||||
;~(plug parse-qualified-2-name parse-as-of)
|
||||
parse-qualified-2-name
|
||||
==
|
||||
end-or-next-command
|
||||
==
|
||||
++ parse-create-index
|
||||
@ -1054,7 +1141,7 @@
|
||||
++ crub-no-text
|
||||
~+
|
||||
;~ pose
|
||||
(cook |=(det=date `dime`[%da (year det)]) when:so)
|
||||
(cook |=(det=date `dime`[%da (year det)]) when) :: when:so
|
||||
::
|
||||
%+ cook
|
||||
|= [a=(list [p=?(%d %h %m %s) q=@]) b=(list @)]
|
||||
@ -1327,6 +1414,39 @@
|
||||
;~(plug root-aura (shim 'A' 'J'))
|
||||
root-aura
|
||||
==
|
||||
++ parse-as-of
|
||||
;~ pfix
|
||||
whitespace
|
||||
;~ plug
|
||||
(cold %as-of (jest 'as of'))
|
||||
;~ pfix
|
||||
whitespace
|
||||
;~ pose
|
||||
;~ plug
|
||||
dem
|
||||
;~ pfix
|
||||
whitespace
|
||||
;~ pose
|
||||
(cold %seconds (jest 'seconds'))
|
||||
(cold %minutes (jest 'minutes'))
|
||||
(cold %hours (jest 'hours'))
|
||||
(cold %days (jest 'days'))
|
||||
(cold %weeks (jest 'weeks'))
|
||||
(cold %months (jest 'months'))
|
||||
(cold %years (jest 'years'))
|
||||
==
|
||||
==
|
||||
;~ pfix
|
||||
whitespace
|
||||
(cold %ago (jest 'ago'))
|
||||
==
|
||||
==
|
||||
;~(pose ;~(pfix sig crub-no-text) crub-no-text)
|
||||
(cold %now (jest 'now'))
|
||||
==
|
||||
==
|
||||
==
|
||||
==
|
||||
++ aggregate-name
|
||||
|= name=@t
|
||||
^- @t
|
||||
|
@ -325,9 +325,16 @@
|
||||
::
|
||||
:: create ASTs
|
||||
::
|
||||
+$ as-of-offset
|
||||
$:
|
||||
%as-of-offset
|
||||
offset=@ud
|
||||
units=?(%seconds %minutes %hours %days %weeks %months %years)
|
||||
==
|
||||
+$ as-of ?(@da as-of-offset)
|
||||
::
|
||||
:: $create-database: $:([%create-database name=@tas])
|
||||
+$ create-database $:([%create-database name=@tas as-of=(unit @da)])
|
||||
+$ create-database $:([%create-database name=@tas as-of=(unit as-of)])
|
||||
::
|
||||
:: $create-index:
|
||||
+$ create-index
|
||||
@ -345,7 +352,7 @@
|
||||
$: %create-namespace
|
||||
database-name=@tas
|
||||
name=@tas
|
||||
as-of=(unit @da)
|
||||
as-of=(unit as-of)
|
||||
==
|
||||
::
|
||||
:: $create-table
|
||||
@ -356,7 +363,7 @@
|
||||
clustered=?
|
||||
pri-indx=(list ordered-column)
|
||||
foreign-keys=(list foreign-key)
|
||||
as-of=(unit @da)
|
||||
as-of=(unit as-of)
|
||||
==
|
||||
::
|
||||
:: $create-trigger: TBD
|
||||
@ -394,14 +401,14 @@
|
||||
::
|
||||
:: $drop-namespace: database-name=@tas name=@tas force=?
|
||||
+$ drop-namespace
|
||||
$:([%drop-namespace database-name=@tas name=@tas force=? as-of=(unit @da)])
|
||||
$:([%drop-namespace database-name=@tas name=@tas force=? as-of=(unit as-of)])
|
||||
::
|
||||
:: $drop-table: table=qualified-object force=?
|
||||
+$ drop-table
|
||||
$: %drop-table
|
||||
table=qualified-object
|
||||
force=?
|
||||
as-of=(unit @da)
|
||||
as-of=(unit as-of)
|
||||
==
|
||||
::
|
||||
:: $drop-trigger: TBD
|
||||
@ -444,7 +451,7 @@
|
||||
object-type=object-type
|
||||
target-namespace=@tas
|
||||
target-name=@tas
|
||||
as-of=(unit @da)
|
||||
as-of=(unit as-of)
|
||||
==
|
||||
::
|
||||
:: $alter-table: to do - this could be simpler
|
||||
@ -457,7 +464,7 @@
|
||||
drop-columns=(list @tas)
|
||||
add-foreign-keys=(list foreign-key)
|
||||
drop-foreign-keys=(list @tas)
|
||||
as-of=(unit @da)
|
||||
as-of=(unit as-of)
|
||||
==
|
||||
::
|
||||
:: $alter-trigger: TBD
|
||||
|
@ -2,7 +2,41 @@
|
||||
/+ parse, *test
|
||||
|%
|
||||
|
||||
::
|
||||
:: create table as of simple name
|
||||
++ test-create-table-08
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~ as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1,col2) as of now"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
|
||||
::
|
||||
:: create table as of ns-qualified name
|
||||
++ test-create-table-08
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~ as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1,col2) as of now"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
|
||||
::
|
||||
:: create table as of db-qualified name
|
||||
++ test-create-table-08
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~ as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1,col2) as of now"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
|
||||
::
|
||||
:: create table as of db-ns-qualified name
|
||||
++ test-create-table-08
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~ as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1,col2) as of now"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
|
||||
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
::
|
||||
|
@ -166,24 +166,78 @@
|
||||
:: create database
|
||||
::
|
||||
:: tests 1, 3, and extra whitespace characters
|
||||
++ test-create-database-1
|
||||
++ test-create-database-00
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-database' as-of=~]]
|
||||
!> (parse:parse(default-database 'dummy') "cReate datAbase \0a my-database ")
|
||||
::
|
||||
:: as of now
|
||||
++ test-create-database-01
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=~]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of now")
|
||||
::
|
||||
:: as of date-time
|
||||
++ test-create-database-02
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ ~2023.12.25..7.15.0..1ef5]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: as of seconds ago
|
||||
++ test-create-database-03
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ [%as-of-offset 5 %seconds]]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of 5 seconds ago")
|
||||
::
|
||||
:: as of minutes ago
|
||||
++ test-create-database-04
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ [%as-of-offset 15 %minutes]]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of 15 minutes ago")
|
||||
::
|
||||
:: as of hours ago
|
||||
++ test-create-database-05
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ [%as-of-offset 9 %hours]]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of 9 hours ago")
|
||||
::
|
||||
:: as of days ago
|
||||
++ test-create-database-06
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ [%as-of-offset 3 %days]]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of 3 days ago")
|
||||
::
|
||||
:: as of weeks ago
|
||||
++ test-create-database-07
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ [%as-of-offset 2 %weeks]]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of 2 weeks ago")
|
||||
::
|
||||
:: as of months ago
|
||||
++ test-create-database-08
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ [%as-of-offset 7 %months]]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of 7 months ago")
|
||||
::
|
||||
:: as of years ago
|
||||
++ test-create-database-09
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-db' as-of=[~ [%as-of-offset 4 %years]]]]
|
||||
!> (parse:parse(default-database 'dummy') "create database my-db as of 4 years ago")
|
||||
::
|
||||
:: subsequent commands ignored
|
||||
++ test-create-database-2
|
||||
++ test-create-database-10
|
||||
%+ expect-eq
|
||||
!> ~[[%create-database name='my-database' as-of=~]]
|
||||
!> (parse:parse(default-database 'dummy') "cReate datAbase \0a my-database; cReate namesPace my-db.another-namespace")
|
||||
::
|
||||
:: fail when database name is not a term
|
||||
++ test-fail-create-database-3
|
||||
++ test-fail-create-database-11
|
||||
%- expect-fail
|
||||
|. (parse:parse(default-database 'dummy') "cReate datAbase My-database")
|
||||
::
|
||||
:: fail when commands are prior to create database
|
||||
++ test-fail-create-database-4
|
||||
++ test-fail-create-database-12
|
||||
%- expect-fail
|
||||
|. (parse:parse(default-database 'dummy') "create namespace my-namespace ; cReate datAbase my-database")
|
||||
::
|
||||
@ -243,33 +297,141 @@
|
||||
:: create namespace
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters
|
||||
++ test-create-namespace-1
|
||||
=/ expected1 [%create-namespace database-name='other-db' name='my-namespace' as-of=~]
|
||||
++ test-create-namespace-00
|
||||
=/ expected1 [%create-namespace database-name='db1' name='ns1' as-of=~]
|
||||
=/ expected2 [%create-namespace database-name='my-db' name='another-namespace' as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected1 expected2]
|
||||
!> (parse:parse(default-database 'other-db') "cReate\0d\09 namespace my-namespace ; cReate namesPace my-db.another-namespace")
|
||||
!> (parse:parse(default-database 'db1') "cReate\0d\09 namespace ns1 ; cReate namesPace my-db.another-namespace")
|
||||
::
|
||||
:: leading and trailing whitespace characters, end delimiter not required on single
|
||||
++ test-create-namespace-2
|
||||
++ test-create-namespace-01
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='other-db' name='my-namespace' as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') " \09cReate\0d\09 namespace my-namespace ")
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=~]]
|
||||
!> (parse:parse(default-database 'db1') " \09cReate\0d\09 namespace ns1 ")
|
||||
::
|
||||
:: as of now simple name
|
||||
++ test-create-namespace-02
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=~]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of now")
|
||||
::
|
||||
:: as of now qualified name
|
||||
++ test-create-namespace-03
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=~]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of now")
|
||||
::
|
||||
:: as of date-time simple name
|
||||
++ test-create-namespace-04
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ ~2023.12.25..7.15.0..1ef5]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: as of date-time qualified name
|
||||
++ test-create-namespace-05
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ ~2023.12.25..7.15.0..1ef5]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: as of seconds ago simple name
|
||||
++ test-create-namespace-06
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ [%as-of-offset 5 %seconds]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of 5 seconds ago")
|
||||
::
|
||||
:: as of seconds ago qualified name
|
||||
++ test-create-namespace-07
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ [%as-of-offset 5 %seconds]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of 5 seconds ago")
|
||||
::
|
||||
:: as of minutes ago simple name
|
||||
++ test-create-namespace-08
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ [%as-of-offset 15 %minutes]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of 15 minutes ago")
|
||||
::
|
||||
:: as of minutes ago qualified name
|
||||
++ test-create-namespace-09
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ [%as-of-offset 15 %minutes]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of 15 minutes ago")
|
||||
::
|
||||
:: as of hours ago simple name
|
||||
++ test-create-namespace-10
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ [%as-of-offset 9 %hours]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of 9 hours ago")
|
||||
::
|
||||
:: as of hours ago qualified name
|
||||
++ test-create-namespace-11
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ [%as-of-offset 9 %hours]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of 9 hours ago")
|
||||
::
|
||||
:: as of days ago simple name
|
||||
++ test-create-namespace-12
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ [%as-of-offset 3 %days]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of3 days ago")
|
||||
::
|
||||
:: as of days ago qualified name
|
||||
++ test-create-namespace-13
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ [%as-of-offset 3 %days]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of3 days ago")
|
||||
::
|
||||
:: as of weeks ago simple name
|
||||
++ test-create-namespace-14
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ [%as-of-offset 2 %weeks]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of 2 weeks ago")
|
||||
::
|
||||
:: as of weeks ago qualified name
|
||||
++ test-create-namespace-15
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ [%as-of-offset 2 %weeks]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of 2 weeks ago")
|
||||
::
|
||||
:: as of months ago simple name
|
||||
++ test-create-namespace-16
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ [%as-of-offset 7 %months]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of 7 months ago")
|
||||
::
|
||||
:: as of months ago qualified name
|
||||
++ test-create-namespace-17
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ [%as-of-offset 7 %months]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of 7 months ago")
|
||||
::
|
||||
:: as of years ago simple name
|
||||
++ test-create-namespace-18
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db1' name='ns1' as-of=[~ [%as-of-offset 4 %years]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace ns1 as of 4 years ago")
|
||||
::
|
||||
:: as of years ago qualified name
|
||||
++ test-create-namespace-19
|
||||
%+ expect-eq
|
||||
!> ~[[%create-namespace database-name='db2' name='ns1' as-of=[~ [%as-of-offset 4 %years]]]]
|
||||
!> (parse:parse(default-database 'db1') "create namespace db2.ns1 as of 4 years ago")
|
||||
::
|
||||
:: fail when database qualifier is not a term
|
||||
++ test-fail-create-namespace-3
|
||||
++ test-fail-create-namespace-20
|
||||
%- expect-fail
|
||||
|. (parse:parse(default-database 'other-db') "cReate namesPace Bad-face.another-namespace")
|
||||
|. (parse:parse(default-database 'db1') "cReate namesPace Bad-face.another-namespace")
|
||||
::
|
||||
:: fail when namespace is not a term
|
||||
++ test-fail-create-namespace-4
|
||||
++ test-fail-create-namespace-21
|
||||
%- expect-fail
|
||||
|. (parse:parse(default-database 'other-db') "cReate namesPace my-db.Bad-face")
|
||||
|. (parse:parse(default-database 'db1') "cReate namesPace my-db.Bad-face")
|
||||
::
|
||||
:: create table
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters, db.ns.table clustered on delete cascade on update cascade; db..table look-up on update cascade on delete cascade
|
||||
++ test-create-table-1
|
||||
++ test-create-table-00
|
||||
=/ expected1 [%create-table table=[%qualified-object ship=~ database='db' namespace='ns' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db' namespace='ns' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db' namespace='dbo' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade %update-cascade]]] as-of=~]
|
||||
=/ expected2 [%create-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.n pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db' namespace='dbo' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade %update-cascade]]] as-of=~]
|
||||
=/ urql1 "crEate taBle db.ns.my-table ( col1 @t , col2 @p , col3 @ud ) pRimary kEy clusTered ( col1 , col2 ) foReign KeY fk ( col1 , col2 desc ) reFerences fk-table ( col19 , col20 ) On dELETE CAsCADE oN UPdATE CAScADE "
|
||||
@ -279,15 +441,15 @@
|
||||
!> (parse:parse(default-database 'db1') (weld urql1 (weld "\0a;\0a" urql2)))
|
||||
::
|
||||
:: leading whitespace characters, whitespace after end delimiter, create look-up table... table ... references ns.fk-table on update no action on delete no action
|
||||
++ test-create-table-2
|
||||
++ test-create-table-01
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.n pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='ns' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~]] as-of=~]
|
||||
=/ urql2 " \0acreate table my-table (col1 @t,col2 @p,col3 @ud) primary key look-up (col1, col2) foreign key fk (col1,col2 desc) reFerences ns.fk-table (col19, col20) on update no action on delete no action; "
|
||||
=/ urql " \0acreate table my-table (col1 @t,col2 @p,col3 @ud) primary key look-up (col1, col2) foreign key fk (col1,col2 desc) reFerences ns.fk-table (col19, col20) on update no action on delete no action; "
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql2)
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: create table... table ... references ns.fk-table on update no action on delete cascade
|
||||
++ test-create-table-3
|
||||
++ test-create-table-02
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='ns' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade]]] as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1, col2) foreign key fk (col1,col2 desc) reFerences ns.fk-table (col19, col20) on update no action on delete cascade"
|
||||
%+ expect-eq
|
||||
@ -295,7 +457,7 @@
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: create table... table ... references fk-table on update cascade on delete no action
|
||||
++ test-create-table-4
|
||||
++ test-create-table-03
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%update-cascade]]] as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1, col2) foreign key fk (col1,col2 desc) reFerences fk-table (col19, col20) on update cascade on delete no action"
|
||||
%+ expect-eq
|
||||
@ -303,7 +465,7 @@
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: create table... table ... single column indices... references fk-table on update cascade
|
||||
++ test-create-table-5
|
||||
++ test-create-table-04
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=~['col20'] referential-integrity=~[%update-cascade]]] as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences fk-table (col20) on update cascade"
|
||||
%+ expect-eq
|
||||
@ -311,7 +473,7 @@
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: create table... table ... single column indices... references fk-table
|
||||
++ test-create-table-6
|
||||
++ test-create-table-05
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=~['col20'] referential-integrity=~]] as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences fk-table (col20) "
|
||||
%+ expect-eq
|
||||
@ -319,7 +481,7 @@
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: create table... no foreign key
|
||||
++ test-create-table-7
|
||||
++ test-create-table-06
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~ as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1,col2)"
|
||||
%+ expect-eq
|
||||
@ -327,7 +489,7 @@
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: create table... 2 foreign keys
|
||||
++ test-create-table-8
|
||||
++ test-create-table-07
|
||||
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=['col20' ~] referential-integrity=~] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table2'] reference-columns=['col19' 'col20' ~] referential-integrity=~]] as-of=~]
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences fk-table (col20), fk2 (col1, col2 desc) reFerences fk-table2 (col19, col20)"
|
||||
%+ expect-eq
|
||||
@ -335,13 +497,13 @@
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: fail when database qualifier on foreign key table db.ns.fk-table
|
||||
++ test-fail-create-table-9
|
||||
++ test-fail-create-table-08
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences db.ns.fk-table (col20) "
|
||||
%- expect-fail
|
||||
|. (parse:parse(default-database 'other-db') urql)
|
||||
::
|
||||
:: fail when database qualifier on foreign key table db..fk-table
|
||||
++ test-fail-create-table-10
|
||||
++ test-fail-create-table-09
|
||||
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences db..fk-table (col20) "
|
||||
%- expect-fail
|
||||
|. (parse:parse(default-database 'other-db') urql)
|
||||
|
Loading…
Reference in New Issue
Block a user