drop database

This commit is contained in:
jackfoxy 2022-08-21 15:01:22 -07:00
parent cfb002faaa
commit 165396b42e
2 changed files with 42 additions and 3 deletions

View File

@ -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
!!

View File

@ -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