mirror of
https://github.com/jackfoxy/urQL.git
synced 2024-09-11 11:55:33 +03:00
alter namespace
This commit is contained in:
parent
528d7739d7
commit
8061cd748f
@ -353,8 +353,8 @@
|
||||
;~(sfix ;~(pose ;~(plug columns action) columns action) end-or-next-command)
|
||||
==
|
||||
++ parse-alter-namespace ;~ plug
|
||||
parse-qualified-2-name
|
||||
;~(pfix ;~(plug whitespace (jester 'transfer') ;~(pose (jester 'table') (jester 'view'))))
|
||||
(cook |=(a=* (qualified-namespace [a current-database])) parse-qualified-2-name)
|
||||
;~(pfix ;~(plug whitespace (jester 'transfer')) ;~(pfix whitespace ;~(pose (jester 'table') (jester 'view'))))
|
||||
;~(sfix ;~(pfix whitespace parse-qualified-3object) end-or-next-command)
|
||||
==
|
||||
++ parse-create-namespace ;~ sfix
|
||||
@ -435,7 +435,7 @@
|
||||
=/ script-position [1 1]
|
||||
=/ parse-command ;~ pose
|
||||
(cold %alter-index ;~(plug whitespace (jester 'alter') whitespace (jester 'index')))
|
||||
(cold %alter-index ;~(plug whitespace (jester 'alter') whitespace (jester 'namespace')))
|
||||
(cold %alter-namespace ;~(plug whitespace (jester 'alter') whitespace (jester 'namespace')))
|
||||
(cold %create-database ;~(plug whitespace (jester 'create') whitespace (jester 'database')))
|
||||
(cold %create-namespace ;~(plug whitespace (jester 'create') whitespace (jester 'namespace')))
|
||||
(cold %create-table ;~(plug whitespace (jester 'create') whitespace (jester 'table')))
|
||||
@ -470,10 +470,6 @@
|
||||
=/ parsed (wonk index-nail)
|
||||
=/ next-cursor
|
||||
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:index-nail])
|
||||
|
||||
~| "parsed: {<parsed>}"
|
||||
~| "remainder: {<q.q.u.+3.q:index-nail>}"
|
||||
|
||||
?: ?=([[@ @ @ @ @] [@ @ @ @ @] * @] [parsed]) ::"alter index columns action"
|
||||
%= $
|
||||
script q.q.u.+3.q:index-nail
|
||||
@ -506,18 +502,12 @@
|
||||
=/ parsed (wonk namespace-nail)
|
||||
=/ next-cursor
|
||||
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:namespace-nail])
|
||||
|
||||
:: ~| "parsed: {<parsed>}"
|
||||
~| "remainder: {<q.q.u.+3.q:namespace-nail>}"
|
||||
|
||||
:: ?: ?=([@ [* *]] [parsed])
|
||||
:: %= $
|
||||
:: script q.q.u.+3.q:namespace-nail
|
||||
:: script-position next-cursor
|
||||
:: commands
|
||||
:: [`command-ast`(alter-namespace:ast %alter-namespace -.parsed +<.parsed %.n %.n +>.parsed) commands]
|
||||
:: ==
|
||||
!!
|
||||
%= $
|
||||
script q.q.u.+3.q:namespace-nail
|
||||
script-position next-cursor
|
||||
commands
|
||||
[`command-ast`(alter-namespace:ast %alter-namespace -<.parsed ->.parsed +<.parsed +>+>+<.parsed +>+>+>.parsed) commands]
|
||||
==
|
||||
%create-database
|
||||
~| 'Create database must be only statement in script'
|
||||
?> =((lent commands) 0)
|
||||
|
@ -8,6 +8,7 @@
|
||||
+$ index-action ?(%rebuild %disable %resume)
|
||||
+$ all-or-any ?(%all %any)
|
||||
+$ bool-conjunction ?(%and %or)
|
||||
+$ object-type ?(%table %view)
|
||||
+$ default-or-column-value ?(%default [@ta @])
|
||||
+$ unary-operator ?(%y %n)
|
||||
+$ constant ?(@ud @t @tas @da @p)
|
||||
@ -314,9 +315,9 @@
|
||||
%alter-namespace
|
||||
database-name=@t
|
||||
source-namespace=@t
|
||||
object-name=@t :: because it can be a table or view
|
||||
is-table=?
|
||||
object-type=object-type :: because it can be a table or view
|
||||
target-namespace=@t
|
||||
target-name=@t
|
||||
==
|
||||
+$ alter-table
|
||||
$:
|
||||
|
@ -68,6 +68,33 @@
|
||||
::
|
||||
:: alter namespace
|
||||
::
|
||||
:: tests 1, 2, 3, 5, and extra whitespace characters, alter namespace db.ns db.ns2.table ; ns db..table
|
||||
++ test-alter-namespace-1
|
||||
=/ expected1 [%alter-namespace database-name='db' source-namespace='ns' object-type=%table target-namespace='ns2' target-name='table']
|
||||
=/ expected2 [%alter-namespace database-name='db1' source-namespace='ns' object-type=%table target-namespace='dbo' target-name='table']
|
||||
%+ expect-eq
|
||||
!> ~[expected1 expected2]
|
||||
!> (parse:parse(current-database 'db1') " ALtER NAmESPACE db.ns TRANsFER TaBLE db.ns2.table \0a;\0a ALTER NAMESPACE ns TRANSFER TABLE db..table ")
|
||||
::
|
||||
:: alter namespace ns table
|
||||
++ test-alter-namespace-2
|
||||
=/ expected [%alter-namespace database-name='db1' source-namespace='ns' object-type=%table target-namespace='dbo' target-name='table'] %+ expect-eq
|
||||
!> ~[expected]
|
||||
!> (parse:parse(current-database 'db1') "ALTER NAMESPACE ns TRANSFER TABLE table ")
|
||||
::
|
||||
:: fail when namespace qualifier is not a term
|
||||
++ test-fail-alter-namespace-3
|
||||
%- expect-fail
|
||||
|. (parse:parse(current-database 'db2') "ALTER NAMESPACE db.nS TRANSFER TABLE db.ns2.table")
|
||||
::
|
||||
:: fail when table name is not a term
|
||||
++ test-fail-alter-namespace-4
|
||||
%- expect-fail
|
||||
|. (parse:parse(current-database 'other-db') "ALTER NAMESPACE db.ns TRANSFER TABLE db.ns2.tAble")
|
||||
::
|
||||
::
|
||||
:: alter table
|
||||
::
|
||||
|
||||
::
|
||||
:: create database
|
||||
|
Loading…
Reference in New Issue
Block a user