mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-09-11 11:55:33 +03:00
drop database
This commit is contained in:
parent
cfb002faaa
commit
165396b42e
@ -34,9 +34,6 @@
|
||||
++ get-next-cursor
|
||||
|= [last-cursor=[@ud @ud] command-hair=[@ud @ud] end-hair=[@ud @ud]]
|
||||
^- [@ud @ud]
|
||||
~& "last-cursor: {<last-cursor>}"
|
||||
~& "command-hair: {<command-hair>}"
|
||||
~& "end-hair: {<end-hair>}"
|
||||
=/ next-hair ?: (gth -.command-hair 1) :: if we advanced to next input line
|
||||
[(sub (add -.command-hair -.last-cursor) 1) +.command-hair] :: add lines and use last column
|
||||
[-.command-hair (sub (add +.command-hair +.last-cursor) 1)] :: else add column positions
|
||||
@ -168,6 +165,27 @@
|
||||
%create-view
|
||||
!!
|
||||
%drop-database
|
||||
=/ parse-drop-database ;~ sfix
|
||||
;~(pose ;~(plug ;~(pfix whitespace (jester 'force')) ;~(pfix whitespace sym)) ;~(pfix whitespace sym))
|
||||
end-or-next-command
|
||||
==
|
||||
~| "Cannot parse drop-database {<p.q.command-nail>}"
|
||||
=/ drop-database-nail (parse-drop-database [[1 1] q.q.command-nail])
|
||||
=/ parsed (wonk drop-database-nail)
|
||||
=/ next-cursor
|
||||
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:drop-database-nail])
|
||||
?@ parsed :: name
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-database-nail
|
||||
script-position next-cursor
|
||||
commands [`command-ast`(drop-database:ast %drop-database parsed %.n) commands]
|
||||
==
|
||||
?: ?=([@ @] parsed) :: force name
|
||||
%= $
|
||||
script q.q.u.+3.q:drop-database-nail
|
||||
script-position next-cursor
|
||||
commands [`command-ast`(drop-database:ast %drop-database +.parsed %.y) commands]
|
||||
==
|
||||
!!
|
||||
%drop-index
|
||||
!!
|
||||
|
@ -70,6 +70,27 @@
|
||||
%- expect-fail
|
||||
|. (parse:parse(current-database 'other-db') "cReate namesPace my-db.Bad-face")
|
||||
::
|
||||
:: drop database
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters, force db.name, name
|
||||
++ test-drop-database-1
|
||||
=/ expected1 [%drop-database name='name' force=%.n]
|
||||
=/ expected2 [%drop-database name='name' force=%.y]
|
||||
%+ expect-eq
|
||||
!> ~[expected1 expected2]
|
||||
!> (parse:parse(current-database 'other-db') "droP Database name;droP \0d\09 DataBase FORce \0a name")
|
||||
::
|
||||
:: leading and trailing whitespace characters, end delimiter not required on single, force name
|
||||
++ test-drop-database-2
|
||||
%+ expect-eq
|
||||
!> ~[[%drop-database name='name' force=%.y]]
|
||||
!> (parse:parse(current-database 'other-db') " \09drOp\0d\09 dAtabaSe\0a force name ")
|
||||
::
|
||||
:: fail when database is not a term
|
||||
++ test-drop-database-3
|
||||
%- expect-fail
|
||||
|. (parse:parse(current-database 'other-db') "DROP DATABASE nAme")
|
||||
::
|
||||
:: drop namespace
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters, force db.name, name
|
||||
|
Loading…
Reference in New Issue
Block a user