mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-09-11 11:55:33 +03:00
drop table
This commit is contained in:
parent
9be59f5585
commit
2770619198
@ -26,7 +26,7 @@ Cannot drop namespaces *dbo* and *sys*.
|
||||
### _______________________________
|
||||
|
||||
|
||||
`DROP TABLE [ FORCE ] [ <db-qualifer> ] { <table-name> }`
|
||||
`DROP TABLE [ FORCE ] [ <db-qualifer> ]{ <table-name> }`
|
||||
|
||||
Discussion:
|
||||
Cannot drop if used in a view or foreign key, unless `FORCE` is specified, resulting in cascading object drops.
|
||||
@ -35,8 +35,7 @@ Cannot drop if used in a view or foreign key, unless `FORCE` is specified, resul
|
||||
|
||||
|
||||
```
|
||||
DROP TRIGGER
|
||||
[ <db-qualifer> ] { <trigger-name> }
|
||||
DROP TRIGGER [ <db-qualifer> ]{ <trigger-name> }
|
||||
ON { <table-name> | <view-name> }
|
||||
```
|
||||
|
||||
@ -53,6 +52,6 @@ Cannot drop if type-name is in use.
|
||||
### _______________________________
|
||||
|
||||
|
||||
`DROP VIEW [ FORCE ] [ <db-qualifer> ] <view-name>`
|
||||
`DROP VIEW [ FORCE ] [ <db-qualifer> ]<view-name>`
|
||||
|
||||
Discussion: Cannot drop if used in another view, unless `FORCE` is specified, resulting in cascading object drops.
|
@ -138,7 +138,91 @@
|
||||
%drop-namespace
|
||||
!!
|
||||
%drop-table
|
||||
=/ parse-drop-table ;~ sfix
|
||||
;~(pose ;~(plug parse-force-or-3-name parse-qualified-3-name) parse-qualified-3-name)
|
||||
end-or-next-command
|
||||
==
|
||||
~| "Cannot parse drop-table {<p.q.command-nail>}"
|
||||
=/ drop-table-nail (parse-drop-table [[1 1] q.q.command-nail])
|
||||
=/ parsed p.u.+3:q.+3:drop-table-nail
|
||||
=/ cursor p.q.u.+3:q.+3:drop-table-nail
|
||||
=/ next-cursor ?: (gth -.cursor -.script-position) :: if we advanced to next input line
|
||||
[(add -.cursor -.script-position) +.cursor] :: add lines and use nail cursor column
|
||||
[-.cursor (add +.cursor +.script-position)] :: else add column positions
|
||||
::
|
||||
:: "drop table force db.ns.name"
|
||||
?: ?=([@ [[@ %~] [@ %~] [@ %~]]] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table i.+<.parsed i.+>-.parsed i.+>+.parsed %.y) commands]
|
||||
==
|
||||
::
|
||||
:: "drop table force db..name"
|
||||
?: ?=([@ [[@ %~] @ @ [@ %~]]] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table i.+<.parsed 'dbo' +>+>-.parsed %.y) commands]
|
||||
==
|
||||
::
|
||||
:: "drop table force ns.name"
|
||||
?: ?=([@ [[@ %~] [@ %~]]] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table current-database i.+<.parsed +>-.parsed %.y) commands]
|
||||
==
|
||||
::
|
||||
:: "drop table force name"
|
||||
?: ?=([@ [@ %~]] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table current-database 'dbo' +<.parsed %.y) commands]
|
||||
==
|
||||
::
|
||||
:: "drop table db.ns.name"
|
||||
?: ?=([[[@ %~] [@ %~] [@ %~]] %~] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table i.-<.parsed i.->-.parsed i.->+.parsed %.n) commands]
|
||||
==
|
||||
::
|
||||
:: "drop table db..name"
|
||||
?: ?=([[[@ %~] @ @ [@ %~]] %~] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table i.-<.parsed 'dbo' ->+>-.parsed %.n) commands]
|
||||
==
|
||||
::
|
||||
:: "drop table ns.name"
|
||||
?: ?=([[[@ %~] [@ %~]] %~] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table current-database i.-<.parsed ->-.parsed %.n) commands]
|
||||
==
|
||||
::
|
||||
:: "drop table name"
|
||||
?: ?=([[@ %~] %~] parsed)
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-table-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(drop-table:ast %drop-table current-database 'dbo' -<.parsed %.n) commands]
|
||||
==
|
||||
!!
|
||||
|
||||
%drop-view
|
||||
=/ parse-drop-view ;~ sfix
|
||||
;~(pose ;~(plug parse-force-or-3-name parse-qualified-3-name) parse-qualified-3-name)
|
||||
|
@ -68,6 +68,64 @@
|
||||
|. (parse:parse ['other-db' "cReate namesPace my-db.Bad-face"])
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters
|
||||
++ test-drop-table-1
|
||||
=/ expected1 [%drop-table database-name='db' namespace='ns' name='name' force=%.y]
|
||||
=/ expected2 [%drop-table database-name='db' namespace='ns' name='name' force=%.n]
|
||||
%+ expect-eq
|
||||
!> ~[expected1 expected2]
|
||||
!> %- parse:parse
|
||||
['other-db' "droP table FORce db.ns.name;droP table \0a db.ns.name"]
|
||||
::
|
||||
:: leading and trailing whitespace characters, end delimiter not required on single
|
||||
++ test-drop-table-2
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='db' namespace='dbo' name='name' force=%.y]]
|
||||
!> (parse:parse ['other-db' " \09drop\0d\09 table\0aforce db..name "])
|
||||
++ test-drop-table-3
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='db' namespace='dbo' name='name' force=%.n]]
|
||||
!> (parse:parse ['other-db' "drop table db..name"])
|
||||
++ test-drop-table-4
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='other-db' namespace='ns' name='name' force=%.y]]
|
||||
!> (parse:parse ['other-db' "drop table force ns.name"])
|
||||
++ test-drop-table-5
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='other-db' namespace='ns' name='name' force=%.n]]
|
||||
!> (parse:parse ['other-db' "drop table ns.name"])
|
||||
++ test-drop-table-6
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='other-db' namespace='ns' name='name' force=%.y]]
|
||||
!> (parse:parse ['other-db' "drop table force ns.name"])
|
||||
++ test-drop-table-7
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='other-db' namespace='ns' name='name' force=%.n]]
|
||||
!> (parse:parse ['other-db' "drop table ns.name"])
|
||||
++ test-drop-table-8
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='other-db' namespace='dbo' name='name' force=%.y]]
|
||||
!> (parse:parse ['other-db' "DROP table FORCE name"])
|
||||
++ test-drop-table-9
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-table database-name='other-db' namespace='dbo' name='name' force=%.n]]
|
||||
!> (parse:parse ['other-db' "DROP table name"])
|
||||
::
|
||||
:: fail when database qualifier is not a face
|
||||
++ test-drop-table-10
|
||||
%- expect-fail
|
||||
|. (parse:parse ['other-db' "DROP table Db.ns.name"])
|
||||
|
||||
:: fail when namespace qualifier is not a face
|
||||
++ test-drop-table-11
|
||||
%- expect-fail
|
||||
|. (parse:parse ['other-db' "DROP table db.nS.name"])
|
||||
::
|
||||
:: fail when table name is not a face
|
||||
++ test-drop-table-12
|
||||
%- expect-fail
|
||||
|. (parse:parse ['other-db' "DROP table db.ns.nAme"])
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters
|
||||
++ test-drop-view-1
|
||||
=/ expected1 [%drop-view database-name='db' namespace='ns' name='name' force=%.y]
|
||||
=/ expected2 [%drop-view database-name='db' namespace='ns' name='name' force=%.n]
|
||||
|
Loading…
Reference in New Issue
Block a user