mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-08-16 23:30:51 +03:00
alter table as of
This commit is contained in:
parent
4801bc7300
commit
c5f18a97e4
@ -214,6 +214,96 @@
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +>.parsed ~) commands]
|
||||
==
|
||||
?: ?&(=(+<-.parsed %alter-column) ?=([* [* %as-of *]] parsed))
|
||||
?: =(%now +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed +<+.parsed ~ ~ ~ ~ ~) commands]
|
||||
==
|
||||
?: ?=([@ @] +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed +<+.parsed ~ ~ ~ ~ [~ +>+>.parsed]) commands]
|
||||
==
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed +<+.parsed ~ ~ ~ ~ [~ (as-of-offset:ast %as-of-offset +>+<.parsed +>+>-.parsed)]) commands]
|
||||
==
|
||||
?: ?&(=(+<-.parsed %add-column) ?=([* [* %as-of *]] parsed))
|
||||
?: =(%now +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ +<+.parsed ~ ~ ~ ~) commands]
|
||||
==
|
||||
?: ?=([@ @] +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ +<+.parsed ~ ~ ~ [~ +>+>.parsed]) commands]
|
||||
==
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ +<+.parsed ~ ~ ~ [~ (as-of-offset:ast %as-of-offset +>+<.parsed +>+>-.parsed)]) commands]
|
||||
==
|
||||
?: ?&(=(+<-.parsed %drop-column) ?=([* [* %as-of *]] parsed))
|
||||
?: =(%now +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ +<+.parsed ~ ~ ~) commands]
|
||||
==
|
||||
?: ?=([@ @] +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ +<+.parsed ~ ~ [~ +>+>.parsed]) commands]
|
||||
==
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ +<+.parsed ~ ~ [~ (as-of-offset:ast %as-of-offset +>+<.parsed +>+>-.parsed)]) commands]
|
||||
==
|
||||
?: ?&(=(+<-.parsed %add-fk) ?=([* [* %as-of *]] parsed))
|
||||
?: =(%now +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ (build-foreign-keys [-.parsed +<+.parsed]) ~ ~) commands]
|
||||
==
|
||||
?: ?=([@ @] +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ (build-foreign-keys [-.parsed +<+.parsed]) ~ [~ +>+>.parsed]) commands]
|
||||
==
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ (build-foreign-keys [-.parsed +<+.parsed]) ~ [~ (as-of-offset:ast %as-of-offset +>+<.parsed +>+>-.parsed)]) commands]
|
||||
==
|
||||
?: ?&(=(+<-.parsed %drop-fk) ?=([* [* %as-of *]] parsed))
|
||||
?: =(%now +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +<+.parsed ~) commands]
|
||||
==
|
||||
?: ?=([@ @] +>+.parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +<+.parsed [~ +>+>.parsed]) commands]
|
||||
==
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +<+.parsed [~ (as-of-offset:ast %as-of-offset +>+<.parsed +>+>-.parsed)]) commands]
|
||||
==
|
||||
~|("Cannot parse table {<p.q.command-nail>}" !!)
|
||||
%create-database
|
||||
~| 'Create database must be only statement in script'
|
||||
@ -373,7 +463,6 @@
|
||||
commands
|
||||
[`command:ast`(create-table:ast %create-table -.parsed +<.parsed +>-<+<.parsed +>-<+>.parsed (build-foreign-keys [-.parsed +>->.parsed]) [~ (as-of-offset:ast %as-of-offset +>+>-.parsed +>+>+<.parsed)]) commands]
|
||||
==
|
||||
|
||||
%= $
|
||||
script q.q.u.+3.q:table-nail
|
||||
commands
|
||||
@ -709,8 +798,17 @@
|
||||
;~(sfix ;~(pfix whitespace parse-qualified-3object) end-or-next-command)
|
||||
==
|
||||
++ parse-alter-table ;~ plug
|
||||
;~(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)
|
||||
;~(pfix whitespace parse-qualified-3object)
|
||||
;~ sfix
|
||||
;~ pose
|
||||
;~ plug
|
||||
;~(pfix whitespace ;~(pose alter-columns add-columns drop-columns add-foreign-key drop-foreign-key))
|
||||
parse-as-of
|
||||
==
|
||||
;~(pfix whitespace ;~(pose alter-columns add-columns drop-columns add-foreign-key drop-foreign-key))
|
||||
==
|
||||
end-or-next-command
|
||||
==
|
||||
==
|
||||
++ parse-create-database
|
||||
;~ pose
|
||||
|
@ -2,82 +2,184 @@
|
||||
/+ parse, *test
|
||||
|%
|
||||
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters
|
||||
++ test-drop-table-00
|
||||
=/ expected1 [%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.y as-of=~]
|
||||
=/ expected2 [%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.n as-of=~]
|
||||
:: alter column db.ns.table 3 columns ; alter column db..table 1 column
|
||||
++ test-alter-table-00
|
||||
=/ expected1 [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
=/ expected2 [%alter-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected1 expected2]
|
||||
!> (parse:parse(default-database 'other-db') "droP table FORce db.ns.name;droP table \0a db.ns.name")
|
||||
!> (parse:parse(default-database 'db1') " ALtER TaBLE db.ns.table AdD COlUMN ( col1 @t , col2 @p , col3 @ud ) \0a;\0a ALTER TABLE db..table ADD COLUMN (col1 @t) ")
|
||||
::
|
||||
:: leading and trailing whitespace characters, end delimiter not required on single, force db..name
|
||||
++ test-drop-table-01
|
||||
:: alter column table 3 columns
|
||||
++ test-alter-table-01
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.y as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') " \09drop\0d\09 table\0aforce db..name ")
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table ALTER COLUMN (col1 @t, col2 @p, col3 @ud)")
|
||||
::
|
||||
:: db..name
|
||||
++ test-drop-table-02
|
||||
:: alter column table 1 column
|
||||
++ test-alter-table-02
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.n as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table db..name")
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table ALTER COLUMN (col1 @t)")
|
||||
::
|
||||
:: force ns.name
|
||||
++ test-drop-table-03
|
||||
:: drop column table 3 columns
|
||||
++ test-alter-table-03
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' 'col2' 'col3' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.y as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table force ns.name")
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table DROP COLUMN (col1, col2, col3)")
|
||||
::
|
||||
:: ns.name
|
||||
++ test-drop-table-04
|
||||
:: drop column table 1 column
|
||||
++ test-alter-table-04
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.n as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table ns.name")
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table DROP COLUMN (col1)")
|
||||
::
|
||||
:: force name
|
||||
++ test-drop-table-05
|
||||
:: add 2 foreign keys, extra spaces and mixed case key words
|
||||
++ test-alter-table-05
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=~]
|
||||
=/ urql "ALTER TABLE table ADD FOREIGN KEY fk ( col1 , col2 desc ) reFerences fk-table ( col19 , col20 ) On dELETE CAsCADE oN UPdATE CAScADE, fk2 ( col1 , col2 desc ) reFerences fk-table2 ( col19 , col20 ) On dELETE CAsCADE oN UPdATE CAScADE "
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.y as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') "DROP table FORCE name")
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: name
|
||||
++ test-drop-table-06
|
||||
:: drop 2 foreign keys, extra spaces
|
||||
++ test-alter-table-06
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.n as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') "DROP table name")
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') " ALTER TABLE mytable DROP FOREIGN KEY ( fk1, fk2 )")
|
||||
::
|
||||
:: drop 2 foreign keys, no extra spaces
|
||||
++ test-alter-table-07
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE db..mytable DROP FOREIGN KEY (fk1,fk2)")
|
||||
::
|
||||
:: drop 1 foreign key
|
||||
++ test-alter-table-08
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='ns' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE ns.mytable DROP FOREIGN KEY (fk1)")
|
||||
|
||||
|
||||
:: force db.ns.name as of now
|
||||
++ test-drop-table-07
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.y as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table force db.ns.name as of now")
|
||||
:: force db..name as of date
|
||||
++ test-drop-table-08
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.y as-of=[~ ~2023.12.25..7.15.0..1ef5]]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table force db..name as of ~2023.12.25..7.15.0..1ef5")
|
||||
:: force ns.name as of weeks ago
|
||||
++ test-drop-table-09
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.y as-of=[~ [%as-of-offset 10 %weeks]]]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table force ns.name as of 10 weeks ago")
|
||||
|
||||
:: name as of now
|
||||
++ test-drop-table-10
|
||||
::
|
||||
:: add column as of now
|
||||
++ test-alter-table-09
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table db.ns.table add column ( col1 @t , col2 @p , col3 @ud ) as of now")
|
||||
::
|
||||
:: add column as of now
|
||||
++ test-alter-table-10
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table db.ns.table add column ( col1 @t , col2 @p , col3 @ud ) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: add column as of 1 weeks ago
|
||||
++ test-alter-table-11
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ [%as-of-offset 1 %weeks]]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table db.ns.table add column ( col1 @t , col2 @p , col3 @ud ) as of 1 weeks ago")
|
||||
::
|
||||
:: alter column as of now
|
||||
++ test-alter-table-12
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.n as-of=~]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table db.ns.name as of now")
|
||||
:: db..name as of date
|
||||
++ test-drop-table-11
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table alter column (col1 @t, col2 @p) as of now")
|
||||
::
|
||||
:: alter column as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-13
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.n as-of=[~ ~2023.12.25..7.15.0..1ef5]]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table db..name as of ~2023.12.25..7.15.0..1ef5")
|
||||
:: name as of weeks ago
|
||||
++ test-drop-table-12
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table alter column (col1 @t, col2 @p, col3 @ud) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: alter column as of 5 days ago
|
||||
++ test-alter-table-14
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ %as-of-offset 5 %days]]
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.n as-of=[~ [%as-of-offset 10 %weeks]]]]
|
||||
!> (parse:parse(default-database 'other-db') "drop table name as of 10 weeks ago")
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table alter column (col1 @t) as of 5 days ago")
|
||||
::
|
||||
:: drop column as of now
|
||||
++ test-alter-table-15
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' 'col2' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table drop column (col1, col2) as of now")
|
||||
::
|
||||
:: drop column as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-16
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table drop column (col1) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: drop column as of 5 days ago
|
||||
++ test-alter-table-17
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' 'col2' 'col3' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ %as-of-offset 5 %days]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table drop column (col1, col2, col3) as of 5 days ago")
|
||||
::
|
||||
:: add 2 foreign keys as of now
|
||||
++ test-alter-table-18
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=~]
|
||||
=/ urql "alter table table add foreign key fk ( col1 , col2 desc ) references fk-table ( col19 , col20 ) on delete cascade on update cascade, fk2 ( col1 , col2 desc ) references fk-table2 ( col19 , col20 ) on delete cascade on update cascade as of now"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: add 2 foreign keys as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-19
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
=/ urql "alter table table add foreign key fk ( col1 , col2 desc ) references fk-table ( col19 , col20 ) on delete cascade on update cascade, fk2 ( col1 , col2 desc ) references fk-table2 ( col19 , col20 ) on delete cascade on update cascade as of ~2023.12.25..7.15.0..1ef5"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: add 2 foreign keys as of 5 days ago
|
||||
++ test-alter-table-20
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=[~ %as-of-offset 5 %days]]
|
||||
=/ urql "alter table table add foreign key fk ( col1 , col2 desc ) references fk-table ( col19 , col20 ) on delete cascade on update cascade, fk2 ( col1 , col2 desc ) references fk-table2 ( col19 , col20 ) on delete cascade on update cascade as of 5 days ago"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: drop 2 foreign keys as of now
|
||||
++ test-alter-table-21
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table mytable drop foreign key ( fk1, fk2 ) as of now")
|
||||
::
|
||||
:: drop 2 foreign keys as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-22
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table mytable drop foreign key ( fk1, fk2 ) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: drop 2 foreign keys as of 5 days ago
|
||||
++ test-alter-table-23
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=[~ %as-of-offset 5 %days]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table mytable drop foreign key ( fk1, fk2 ) as of 5 days ago")
|
||||
|
||||
|
||||
|
||||
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|
||||
|
@ -94,7 +94,7 @@
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters
|
||||
:: alter column db.ns.table 3 columns ; alter column db..table 1 column
|
||||
++ test-alter-table-1
|
||||
++ test-alter-table-00
|
||||
=/ expected1 [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
=/ expected2 [%alter-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
@ -102,35 +102,35 @@
|
||||
!> (parse:parse(default-database 'db1') " ALtER TaBLE db.ns.table AdD COlUMN ( col1 @t , col2 @p , col3 @ud ) \0a;\0a ALTER TABLE db..table ADD COLUMN (col1 @t) ")
|
||||
::
|
||||
:: alter column table 3 columns
|
||||
++ test-alter-table-2
|
||||
++ test-alter-table-01
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table ALTER COLUMN (col1 @t, col2 @p, col3 @ud)")
|
||||
::
|
||||
:: alter column table 1 column
|
||||
++ test-alter-table-3
|
||||
++ test-alter-table-02
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table ALTER COLUMN (col1 @t)")
|
||||
::
|
||||
:: drop column table 3 columns
|
||||
++ test-alter-table-4
|
||||
++ test-alter-table-03
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' 'col2' 'col3' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table DROP COLUMN (col1, col2, col3)")
|
||||
::
|
||||
:: drop column table 1 column
|
||||
++ test-alter-table-5
|
||||
++ test-alter-table-04
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE table DROP COLUMN (col1)")
|
||||
::
|
||||
:: add 2 foreign keys, extra spaces and mixed case key words
|
||||
++ test-alter-table-6
|
||||
++ test-alter-table-05
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=~]
|
||||
=/ urql "ALTER TABLE table ADD FOREIGN KEY fk ( col1 , col2 desc ) reFerences fk-table ( col19 , col20 ) On dELETE CAsCADE oN UPdATE CAScADE, fk2 ( col1 , col2 desc ) reFerences fk-table2 ( col19 , col20 ) On dELETE CAsCADE oN UPdATE CAScADE "
|
||||
%+ expect-eq
|
||||
@ -138,28 +138,136 @@
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: drop 2 foreign keys, extra spaces
|
||||
++ test-alter-table-7
|
||||
++ test-alter-table-06
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') " ALTER TABLE mytable DROP FOREIGN KEY ( fk1, fk2 )")
|
||||
::
|
||||
:: drop 2 foreign keys, no extra spaces
|
||||
++ test-alter-table-8
|
||||
++ test-alter-table-07
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE db..mytable DROP FOREIGN KEY (fk1,fk2)")
|
||||
::
|
||||
:: drop 1 foreign key
|
||||
++ test-alter-table-9
|
||||
++ test-alter-table-08
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='ns' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "ALTER TABLE ns.mytable DROP FOREIGN KEY (fk1)")
|
||||
::
|
||||
:: add column as of now
|
||||
++ test-alter-table-09
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table db.ns.table add column ( col1 @t , col2 @p , col3 @ud ) as of now")
|
||||
::
|
||||
:: add column as of now
|
||||
++ test-alter-table-10
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table db.ns.table add column ( col1 @t , col2 @p , col3 @ud ) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: add column as of 1 weeks ago
|
||||
++ test-alter-table-11
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db' namespace='ns' name='table'] alter-columns=~ add-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ [%as-of-offset 1 %weeks]]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table db.ns.table add column ( col1 @t , col2 @p , col3 @ud ) as of 1 weeks ago")
|
||||
::
|
||||
:: alter column as of now
|
||||
++ test-alter-table-12
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table alter column (col1 @t, col2 @p) as of now")
|
||||
::
|
||||
:: alter column as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-13
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table alter column (col1 @t, col2 @p, col3 @ud) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: alter column as of 5 days ago
|
||||
++ test-alter-table-14
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~[[%column name='col1' column-type=%t]] add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ %as-of-offset 5 %days]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table alter column (col1 @t) as of 5 days ago")
|
||||
::
|
||||
:: drop column as of now
|
||||
++ test-alter-table-15
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' 'col2' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table drop column (col1, col2) as of now")
|
||||
::
|
||||
:: drop column as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-16
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table drop column (col1) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: drop column as of 5 days ago
|
||||
++ test-alter-table-17
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=['col1' 'col2' 'col3' ~] add-foreign-keys=~ drop-foreign-keys=~ as-of=[~ %as-of-offset 5 %days]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table table drop column (col1, col2, col3) as of 5 days ago")
|
||||
::
|
||||
:: add 2 foreign keys as of now
|
||||
++ test-alter-table-18
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=~]
|
||||
=/ urql "alter table table add foreign key fk ( col1 , col2 desc ) references fk-table ( col19 , col20 ) on delete cascade on update cascade, fk2 ( col1 , col2 desc ) references fk-table2 ( col19 , col20 ) on delete cascade on update cascade as of now"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: add 2 foreign keys as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-19
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
=/ urql "alter table table add foreign key fk ( col1 , col2 desc ) references fk-table ( col19 , col20 ) on delete cascade on update cascade, fk2 ( col1 , col2 desc ) references fk-table2 ( col19 , col20 ) on delete cascade on update cascade as of ~2023.12.25..7.15.0..1ef5"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: add 2 foreign keys as of 5 days ago
|
||||
++ test-alter-table-20
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='table'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='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=~[%delete-cascade %update-cascade]]] drop-foreign-keys=~ as-of=[~ %as-of-offset 5 %days]]
|
||||
=/ urql "alter table table add foreign key fk ( col1 , col2 desc ) references fk-table ( col19 , col20 ) on delete cascade on update cascade, fk2 ( col1 , col2 desc ) references fk-table2 ( col19 , col20 ) on delete cascade on update cascade as of 5 days ago"
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') urql)
|
||||
::
|
||||
:: drop 2 foreign keys as of now
|
||||
++ test-alter-table-21
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=~]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table mytable drop foreign key ( fk1, fk2 ) as of now")
|
||||
::
|
||||
:: drop 2 foreign keys as of ~2023.12.25..7.15.0..1ef5
|
||||
++ test-alter-table-22
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=[~ ~2023.12.25..7.15.0..1ef5]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table mytable drop foreign key ( fk1, fk2 ) as of ~2023.12.25..7.15.0..1ef5")
|
||||
::
|
||||
:: drop 2 foreign keys as of 5 days ago
|
||||
++ test-alter-table-23
|
||||
=/ expected [%alter-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='mytable'] alter-columns=~ add-columns=~ drop-columns=~ add-foreign-keys=~ drop-foreign-keys=['fk1' 'fk2' ~] as-of=[~ %as-of-offset 5 %days]]
|
||||
%+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(default-database 'db1') "alter table mytable drop foreign key ( fk1, fk2 ) as of 5 days ago")
|
||||
::
|
||||
:: fail when table name not a term
|
||||
++ test-fail-alter-table-10
|
||||
++ test-fail-alter-table-24
|
||||
%- expect-fail
|
||||
|. (parse:parse(default-database 'db1') "ALTER TABLE ns.myTable DROP FOREIGN KEY (fk1)")
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user