as of ddl builds and tests

This commit is contained in:
jackfoxy 2023-10-23 12:23:17 -07:00
parent 066d3f8f5b
commit 89d0d8c76f
23 changed files with 1017 additions and 993 deletions

550
docs/02-ddl Normal file
View File

@ -0,0 +1,550 @@
# CREATE DATABASE
Creates a new user-space database accessible to any agent running on the ship. There is no sandboxing implemented.
_To Do NOTE_: Additional features like owner-desk property and GRANT desk permissions are under development.
```
<create-database> ::=
CREATE DATABASE <database>
[ AS OF { NOW
| <timestamp>
| n { SECONDS | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS } AGO
| <inline-scalar>
}
]
```
## Example
```
CREATE DATABASE my-database
```
## API
```
+$ create-database $:([%create-database name=@tas as-of=(unit @da)])
```
## Arguments
**`<database>`**
The user-defined name for the new database. It must comply with the Hoon term naming standard.
**`AS OF`**
Timestamp of database creation. Defaults to current time. Subsequent DDL and data actions must have timestamps equal to or greater than this timestamp.
## Remarks
This command mutates the state of the Obelisk agent.
`CREATE DATABASE` must be executed independently within a script. The script will fail if there are prior commands. Subsequent commands will be ignored.
## Produced Metadata
INSERT row into `sys.sys.databases`.
## Example
create-database %db1
## Exceptions
"duplicate key: {<key>}" database already exists
# DROP DATABASE
Deletes an existing `<database>` and all associated objects.
```
<drop-database> ::= DROP DATABASE [ FORCE ] <database>
```
## API
```
+$ drop-database
$:
%drop-database
name=@tas
force=?
==
```
## Arguments
**`FORCE`**
Optionally, force deletion of a database.
**`<database>`**
The name of the database to delete.
## Remarks
This command mutates the state of the Obelisk agent.
The command only succeeds when no populated tables exist in the database, unless `FORCE` is specified.
## Produced Metadata
DELETE row from `sys.sys.databases`.
## Exceptions
`<database>` does not exist.
`<database>` has populated tables and FORCE was not specified.
# CREATE NAMESPACE
Namespaces group various database components, including tables and views. When not explicitly specified, namespace designations default to `dbo`.
```
<create-namespace> ::=
CREATE NAMESPACE [<database>.]<namespace>
[ AS OF { NOW
| <timestamp>
| n { SECONDS | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS } AGO
| <inline-scalar>
}
]
```
## Example
`CREATE NAMESPACE my-namespace`
## API
```
+$ create-namespace
database-name=@tas
name=@tas
as-of=(unit @da)
==
```
## Arguments
**`<namespace>`**
This is a user-defined name for the new namespace. It must adhere to the hoon term naming standard.
Note: The "sys" namespace is reserved for system use.
**`AS OF`**
Timestamp of namespace creation. Defaults to current time. When specified timestamp must be equal to or greater than latest system timestamp for the database.
## Remarks
This command mutates the state of the Obelisk agent.
## Produced Metadata
system timestamp
## Exceptions
"duplicate key: {<key>}" namespace already exists
AS OF less than latests system timestamp
# ALTER NAMESPACE
Transfer an existing user `<table>` or `<view>` to another `<namespace>`.
```
<alter-namespace> ::=
ALTER NAMESPACE [ <database>. ]<namespace>
TRANSFER { TABLE | VIEW } [ <db-qualifer> ]{ <table> | <view> }
[ AS OF { NOW
| <timestamp>
| n { SECONDS | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS } AGO
| <inline-scalar>
}
]
```
## API
```
+$ alter-namespace
$: %alter-namespace
database-name=@tas
source-namespace=@tas
object-type=object-type
target-namespace=@tas
target-name=@tas
as-of=(unit @da)
==
```
## Arguments
**`<namespace>`**
Name of the target namespace into which the object is to be transferred.
**`TABLE | VIEW`**
Indicates the type of the target object.
**`<table> | <view>`**
Name of the object to be transferred to the target namespace.
**`AS OF`**
Timestamp of namespace update. Defaults to current time. When specified timestamp must be equal to or greater than latest system timestamp for the database.
## Remarks
This command mutates the state of the Obelisk agent.
Objects cannot be transferred in or out of namespace *sys*.
## Produced Metadata
update `<database>.sys.tables`
update `<database>.sys.views`
## Exceptions
namespace does not exist
`<table>` or `<view>` does not exist
AS OF less than latests system timestamp
# DROP NAMESPACE
Deletes a `<namespace>` and all its associated objects.
```
<drop-namespace> ::=
DROP NAMESPACE [ FORCE ] [ <database>. ]<namespace>
[ AS OF { NOW
| <timestamp>
| n { SECONDS | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS } AGO
| <inline-scalar>
}
]
```
## API
```
+$ drop-namespace
$:
%drop-namespace
database-name=@tas
name=@tas
force=?
as-of=(unit @da)
==
```
## Arguments
**`FORCE`**
Optionally, force deletion of `<namespace>`.
**`<namespace>`**
The name of `<namespace>` to delete.
**`AS OF`**
Timestamp of namespace deletion. Defaults to current time. When specified timestamp must be equal to or greater than latest system timestamp for the database.
## Remarks
This command mutates the state of the Obelisk agent.
Only succeeds when no *populated* `<table>`s are in the namespace, unless `FORCE` is specified, possibly resulting in cascading object drops described in `DROP TABLE`.
The namespaces *dbo* and *sys* cannot be dropped.
## Produced Metadata
DELETE row from `<database>.sys.namespaces`.
## Exceptions
`<namespace>` does not exist.
`<namespace>` has populated tables and FORCE was not specified.
`AS OF` specified and not less than latest system timestamp for database.
# CREATE TABLE
`<table>`s are the only means of indexed persistent `<table-sets>`s in Obelisk.
Any update to `<table>` contents results in a state change of the Obelisk agent.
_NOTE_: Further investigation is needed to understand if there's a reason to specify foreign key names (see CREATE INDEX).
```
<create-table> ::=
CREATE TABLE
[ <db-qualifer> ]<table>
( <column> <aura>
[ ,... n ] )
PRIMARY KEY [ CLUSTERED | LOOK-UP ] ( <column> [ ,... n ] )
[ { FOREIGN KEY <foreign-key> ( <column> [ ASC | DESC ] [ ,... n ] )
REFERENCES [ <namespace>. ] <table> ( <column> [ ,... n ] )
[ ON DELETE { NO ACTION | CASCADE | SET DEFAULT } ]
[ ON UPDATE { NO ACTION | CASCADE | SET DEFAULT } ] }
[ ,... n ] ]
[ AS OF { NOW
| <timestamp>
| n { SECONDS | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS } AGO
| <inline-scalar>
}
]
```
## API
```
+$ create-table
$:
%create-table
table=qualified-object
columns=(list column)
clustered=?
pri-indx=(list ordered-column)
foreign-keys=(list foreign-key)
as-of=(unit @da)
==
```
## Arguments
**`<table>`**
This is a user-defined name for the new table. It must adhere to the hoon term naming standard.
If not explicitly qualified, it defaults to the Obelisk agent's current database and the 'dbo' namespace..
**`<column> <aura>`**
The list of user-defined column names and associated auras. Names must adhere to the hoon term naming standard.
For more details, refer to [ref-ch02-types](ref-ch02-types.md)
**`[ CLUSTERED | LOOK-UP ] ( <column> [ ,... n ]`**
These are column names in the required unique primary index. Defining the index as `LOOK-UP` is optional.
**`<foreign-key> ( <column> [ ASC | DESC ] [ ,... n ]`**
This is a user-defined name for `<foreign-key>`. It must adhere to the hoon term naming standard.
This list comprises column names in the table for association with a foreign table along with sort ordering. Default is `ASC` (ascending).
**`<table> ( <column> [ ,... n ]`**
Referenced foreign `<table>` and columns. Count and associated column auras must match the specified columns from the new `<table>` and comprise a `UNIQUE` index on the referenced foreign `<table>`.
**`ON DELETE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is deleted from the foreign table.
* NO ACTION (default)
The Obelisk agent raises an error and the delete action on the row in the parent foreign table is aborted.
* CASCADE
Corresponding rows are deleted from the referencing table when that row is deleted from the parent foreign table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is deleted.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
**`ON UPDATE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is updated in the foreign table.
* NO ACTION (default)
The Database Engine raises an error and the update action on the row in the parent table is aborted.
* CASCADE
Corresponding rows are updated in the referencing table when that row is updated in the parent table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is updated.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
**`AS OF`**
Timestamp of table creation. Defaults to current time. When specified timestamp must be equal to or greater than system timestamp for the database creation.
## Remarks
This command mutates the state of the Obelisk agent.
`PRIMARY KEY` must be unique.
`FOREIGN KEY` constraints ensure data integrity for the data contained in the column or columns. They necessitate that each value in the column exists in the corresponding referenced column or columns in the referenced table. `FOREIGN KEY` constraints can only reference columns that are subject to a `PRIMARY KEY` or `UNIQUE INDEX` constraint in the referenced table.
NOTE: The specific definition of `CLUSTERED` in Hoon, possibly an ordered map, is to be determined during development.
## Produced Metadata
## Exceptions
name within namespace already exists for table
table referenced by FOREIGN KEY does not exist
table column referenced by FOREIGN KEY does not exist
aura mis-match in FOREIGN KEY
AS OF timestamp prior to database creation
## Example
```
CREATE TABLE order-detail
(invoice-nbr @ud, line-item @ud, product-id @ud, special-offer-id @ud, message @t)
PRIMARY KEY CLUSTERED (invoice-nbr, line-item)
FOREIGN KEY fk-special-offer-order-detail (product-id, specialoffer-id)
REFERENCES special-offer (product-id, special-offer-id)
```
# ALTER TABLE
Modify the columns and/or `<foreign-key>`s of an existing `<table>`.
```
<alter-> ::=
ALTER TABLE [ <db-qualifer> ]{ <table> }
{ ADD COLUMN ( <column> <aura> [ ,... n ] )
| ALTER COLUMN ( <column> <aura> [ ,... n ] )
| DROP COLUMN ( <column> [ ,... n ] )
| ADD FOREIGN KEY <foreign-key> (<column> [ ,... n ])
REFERENCES [<namespace>.]<table> (<column> [ ,... n ])
[ ON DELETE { NO ACTION | CASCADE } ]
[ ON UPDATE { NO ACTION | CASCADE } ]
[ ,... n ]
| DROP FOREIGN KEY ( <foreign-key> [ ,... n ] } )
[ AS OF { NOW
| <timestamp>
| n { SECONDS | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS } AGO
| <inline-scalar>
}
]
```
Example:
```
ALTER TABLE my-table
DROP FOREIGN KEY fk-1, fk-2
```
## API
```
+$ alter-table
$:
%alter-table
table=qualified-object
alter-columns=(list column)
add-columns=(list column)
drop-columns=(list @tas)
add-foreign-keys=(list foreign-key)
drop-foreign-keys=(list @tas)
as-of=(unit @da)
==
```
## Arguments
**`<table>`**
Name of `<table>` to alter.
**`ADD | ALTER COLUMN ( <column> <aura> [ ,... n ] )`**
Denotes a list of user-defined column names and associated auras. `ALTER` is used to change the aura of an existing column.
Names must follow the Hoon term naming standard. See [ref-ch02-types](ref-ch02-types.md)
**`DROP COLUMN ( <column> [ ,... n ] )`**
Denotes a list of existing column names to delete from the `<table>` structure.
**`[ NONCLUSTERED | CLUSTERED ] ( <column> [ ,... n ]`**
These are column names in the required unique primary index. Defining the index as `CLUSTERED` is optional.
**`ADD | DROP`**
The action is to add or drop a foreign key.
**`<foreign-key> ( <column> [ ASC | DESC ] [ ,... n ]`**
This is a user-defined name for `<foreign-key>`. It must adhere to the hoon term naming standard.
This list comprises column names in the table for association with a foreign table along with sort ordering. Default is `ASC` (ascending).
**`<table> ( <column> [ ,... n ]`**
Referenced foreign `<table>` and columns. Count and associated column auras must match the specified columns from the new `<table>` and comprise a `UNIQUE` index on the referenced foreign `<table>`.
**`ON DELETE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is deleted from the foreign table.
* NO ACTION (default)
The Obelisk agent raises an error and the delete action on the row in the parent foreign table is aborted.
* CASCADE
Corresponding rows are deleted from the referencing table when that row is deleted from the parent foreign table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is deleted.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
**`ON UPDATE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is updated in the foreign table.
* NO ACTION (default)
The Database Engine raises an error and the update action on the row in the parent table is aborted.
* CASCADE
Corresponding rows are updated in the referencing table when that row is updated in the parent table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is updated.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
**`AS OF`**
Timestamp of table aleration. Defaults to current time. When specified timestamp must be greater than latest database system timestamp structurally affecting table.
## Remarks
This command mutates the state of the Obelisk agent.
`FOREIGN KEY` constraints ensure data integrity for the data contained in the column or columns. They necessitate that each value in the column exists in the corresponding referenced column or columns in the referenced table. `FOREIGN KEY` constraints can only reference columns that are subject to a `PRIMARY KEY` or `UNIQUE INDEX` constraint in the referenced table.
## Produced Metadata
update `<database>.sys.table-columns`
update `<database>.sys.table-columns`
update `<database>.sys.table-ref-integrity`
## Exceptions
alter a column that does not exist
add a column that does exist
drop a column that does not exist
table referenced by FOREIGN KEY does not exist
table column referenced by FOREIGN KEY does not exist
aura mis-match in FOREIGN KEY
AS OF timestamp prior to latest system timestamp for table
# DROP TABLE
Deletes a `<table>` and all associated objects
```
<drop-table> ::=
DROP TABLE [ FORCE ] [ <db-qualifer> ]{ <table> }
[ AS OF { NOW
| <timestamp>
| n { SECONDS | MINUTES | HOURS | DAYS | WEEKS | MONTHS | YEARS } AGO
| <inline-scalar>
}
]
```
## API
```
+$ drop-table
$:
%drop-table
table=qualified-object
force=?
as-of=(unit @da)
==
```
## Arguments
**`FORCE`**
Optionally, force deletion of a table.
**`<table>`**
Name of `<table>` to delete.
**`AS OF`**
Timestamp of table deletion. Defaults to current time. When specified timestamp must be greater than latest database system timestamp.
## Remarks
This command mutates the state of the Obelisk agent.
Cannot drop if used in a view or foreign key, unless `FORCE` is specified, resulting in cascading object drops.
Cannot drop when the `<table>` is populated unless `FORCE` is specified.
## Produced Metadata
DELETE from `<database>.sys.tables`.
DELETE from `<database>.sys.views`.
DELETE from `<database>.sys.indices`.
## Exceptions
`<table>` does not exist.
`<table>` is populated and FORCE was not specified.
`<table>` used in `<view>` and FORCE was not specified.
`<table>` used in `<foreign-key>` and FORCE was not specified.
AS OF `<timestamp>` prior to latest system timestamp `<timestamp>`.

View File

@ -0,0 +1,163 @@
# CREATE INDEX
This command creates an index over selected column(s) of an existing table.
```
<create-index> ::=
CREATE [ UNIQUE ] [ LOOK-UP | CLUSTERED ] INDEX <index>
ON [ <db-qualifer> ] <table>
( <column> [ ASC | DESC ] [ ,...n ] )
```
## Examples
```
CREATE INDEX ix_vendor-id ON product-vendor (vendor-id);
CREATE UNIQUE INDEX ix_vendor-id2 ON dbo.product-vendor
(vendor-id DESC, name ASC, address DESC);
CREATE INDEX ix_vendor-id3 ON purchasing..product-vendor (vendor-id);
```
## API
```
+$ create-index
$:
%create-index
name=@t
object-name=qualified-object :: because index can be over table or view
is-unique=?
is-clustered=?
columns=(list ordered-column)
==
```
## Arguments
**`UNIQUE`**
Specifies that no two rows are permitted to have the same index key value.
**`LOOK-UP | CLUSTERED`**
`CLUSTERED` creates an index in which the logical order of the key values determines the physical order of the corresponding rows in a table. A `<table>` or `<view>` can have only one clustered index at a time.
**`<index>`**
User-defined name for the new index. This name must follow the Hoon term naming standard.
**`<table>`**
Name of existing table the index targets.
If not explicitly qualified, defaults to the Obelisk agent's current database and 'dbo' namespace.
**`<column> [ ASC | DESC ] [ ,...n ] `**
List of column names in the target table. This list represents the sort hierarchy and optionally specifies the sort direction for each level. The default sorting is `ASC` (ascending).
## Remarks
This command mutates the state of the Obelisk agent.
Index names cannot start with 'pk-' or 'fk-' as these prefixes are reserved for primary keys and foreign keys respectively.
_NOTE_: Further investigation is required to determine how "clustering" works in Hoon.
## Produced Metadata
## Example
INSERT `table name`, `namespace` `index-name`, `LOOK-UP | CLUSTERED`, `is-unique`, `<timestamp>` into `<database>.sys.indices`
## Exceptions
index name already exists for table
table does not exist
column does not exist
UNIQUE specified and existing values are not unique for the column(s) specified
index name begins with 'pk-' or 'fk-'
# CREATE PROCEDURE
Procedures are parameterized urQL scripts.
```
<create-proc> ::=
CREATE { PROC | PROCEDURE }
[<db-qualifer>]<procedure>
[ { #<parameter> <data-type> } ] [ ,...n ]
AS { <urql command>; | *hoon } [ ;...n ]
```
## Remarks
TBD
Cannot be used to create a database.
# CREATE TRIGGER
A trigger automatically runs when a specified table or view event occurs in the Obelisk agent. It runs a previously defined `<procedure>`.
An `INSTEAD OF` trigger fires before the triggering event can occur and replaces it. Otherwise the procedure runs after the triggering event succedes and all state changed by both the triggering event and trigger `<procedure>` is included in one and the same state change.
Triggering events are `INSERT`, `UPDATE`, and `DELETE` statements on a `<table>` and simple execution in the case of `<view>`.
```
<create-trigger> ::=
CREATE TRIGGER [ <db-qualifer> ]<trigger>
ON { <table> | <view> }
{ AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
AS <procedure>
[ ENABLE | DISABLE ]
```
## Remarks
TBD
This command could be used to trigger any database process or agent.
# CREATE TYPE
TBD
`CREATE TYPE <type>`
# CREATE VIEW
A view creates a `<table-set>` whose contents (columns and rows) are defined by a `<transform>`.
The possibility of caching of views is TBD.
```
<create-view> ::=
CREATE VIEW [ <db-qualifer> ]<view> AS <transform>
```
## API
```
+$ create-view
$:
%create-view
view=qualified-object
query=transform
==
```
## Arguments
**`<view>`**
The user-defined name for the new view, which must adhere to the Hoon term naming standard.
**`<transform>`**
The `<transform>` that produces the output `<table-set>`.
## Remarks
This command mutates the state of the Obelisk agent.
Views are read only.
The final step of the `<transform>` must establish unique column names, whether inherited from prior `<table-set>`s or aliased columns.
Views cannot be defined on foreign ship databases.
## Produced Metadata
## Examples
INSERT `name`, `<transform>`, `<timestamp>` INTO `<database>.sys.views`
INSERT `name`, `<ordinal>`, `<column>` INTO `<database>.sys.view-columns`
## Exceptions
view already exists

View File

@ -0,0 +1,121 @@
# ALTER INDEX
Modifies the structure of an existing `<index>` on a user `<table>` or `<view>`.
```
<alter-index> ::=
ALTER [ UNIQUE ] [ NONCLUSTERED | CLUSTERED ] INDEX [ <db-qualifer> ]<index>
ON { <table> | <view> }
[ ( <column> [ ASC | DESC ] [ ,...n ] ) ]
{ DISABLE | RESUME}
```
## API
```
+$ alter-index
$:
%alter-index
name=qualified-object
object=qualified-object
columns=(list ordered-column)
action=index-action
==
```
## Arguments
**`UNIQUE`**
Specifies that no two rows are permitted to have the same index key value.
**`NONCLUSTERED | CLUSTERED`**
`CLUSTERED` creates an index in which the logical order of the key values determines the physical order of the corresponding rows in a table. A `<table>` or `<view>` can have only one clustered index at a time.
**`[ <db-qualifer> ]<index>`**
Specifies the target index.
**`<table> | <view>`**
Name of the underlying object of the index.
**`<column> [ ASC | DESC ] [ ,...n ] `**
List of column names in the target table. This list represents the sort hierarchy and optionally specifies the sort direction for each level. The default sorting is `ASC` (ascending).
**`DISABLE | RESUME`**
Used to disable an active index or resume a disabled index.
## Remarks
This command mutates the state of the Obelisk agent.
Cannot alter primary key and foreign key indices.
`RESUME` will rebuild the index if the underlying object is dirty.
Note: Further investigation into hoon ordered maps is needed to determine what exactly "clustered" means in hoon.
## Produced Metadata
update `<database>.sys.indices`
## Exceptions
index name does not exist for table
table does not exist
column does not exist
UNIQUE specified and existing values are not unique for the column(s) specified
# ALTER PROCEDURE
TBD
```
<alter-proc> ::=
ALTER { PROC | PROCEDURE }
[<db-qualifer>]<procedure>
[ { #<parameter> <data-type> } ] [ ,...n ]
AS { <urql command>; | *hoon } [ ;...n ]
```
# ALTER TRIGGER
TBD
```
<alter-trigger> ::=
ALTER TRIGGER { [ <db-qualifer> ]{ <trigger> } | ALL }
ON { SERVER | <database.name> | <table> | <view> }
[ ENABLE | DISABLE ]
```
# ALTER VIEW
Alter the structure of an existing `<view>`.
```
<alter-view> ::=
ALTER VIEW [ <db-qualifer> ]{ <view> }
( { [<alias>.] <column> } [ ,...n ] )
AS <select_statement>
```
## API
```
+$ alter-view
$:
%alter-view
view=qualified-object
transform
==
```
## Arguments
**`<view>`**
Specifies the name of the view to alter.
**`<transform>`**
Refers to the `<transform>` producing the output `<table-set>`.
## Remarks
This command mutates the state of the Obelisk agent.
## Produced Metadata
UPDATE `<database>.sys.views`
UPDATE `<database>.sys.view-columns`
## Exceptions
view does not exist.

104
docs/in-progress/ref-ch11-drop.md Executable file
View File

@ -0,0 +1,104 @@
# DROP INDEX
Deletes an existing `<index>`.
```
<drop-index> ::=
DROP INDEX <index>
ON [ <db-qualifer> ] { <table> | <view> }
```
## API
```
+$ drop-index
$:
%drop-index
name=@tas
object=qualified-object
==
```
## Arguments
**`<index>`**
The name of the index to delete.
**`<table> | <view>`**
`<table>` or `<view>` with the named index.
## Remarks
This command mutates the state of the Obelisk agent.
Indexes with names that begin with "pk-" cannot be dropped, as these are table primary keys.
This command can be used to delete a `<foreign-key>`.
If `<view>` is shadowing `<table>`, the system attempts to find `<index>` on `<view>` first, then `<table>`.
## Produced Metadata
DELETE FROM `<database>.sys.indices`
DELETE FROM `<database>.sys.table-ref-integrity`
## Exceptions
`<table>` or `<view>` does not exist
`<index>` does not exist on `<table>` or `<view>`.
# DROP TRIGGER
TBD
```
<drop-trigger> ::=
DROP TRIGGER [ <db-qualifer> ]{ <trigger> }
ON { <table> | <view> }
```
# DROP TYPE
TBD
`DROP TYPE <type>`
## Remarks
Cannot drop if type-name is in use.
# DROP VIEW
```
<drop-view> ::= DROP VIEW [ FORCE ] [ <db-qualifer> ]<view>
```
## API
```
+$ drop-view
$:
%drop-view
view=qualified-object
force=?
==
```
## Arguments
**`FORCE`**
Force delete of `<view>`.
**`<view>`**
Name of `<view>` to delete.
## Remarks
This command mutates the state of the Obelisk agent.
Views that are in use in another view cannot be dropped unless `FORCE` is specified, which may result in cascading object drops.
## Produced Metadata
DELETE from `<database>.sys.views`.
## Exceptions
`<view>` does not exist.
`<view>` is in use by other `<view>` and FORCE was not specified.

View File

@ -1,358 +0,0 @@
# CREATE DATABASE
This command creates a new user-space database accessible to any agent running on the ship. There is no sandboxing implemented.
_NOTE_: Additional features like owner-desk property and GRANT desk permissions are under consideration.
```
<create-database> ::=
CREATE DATABASE <database>
```
## Example
```
CREATE DATABASE my-database
```
## API
```
+$ create-database $:([%create-database name=@tas])
```
## Arguments
**`<database>`**
This is the user-defined name for the new database. It must comply with the Hoon term naming standard.
## Remarks
This command mutates the state of the Obelisk agent.
`CREATE DATABASE` must be executed independently within a script. The script will fail if there are prior commands. Subsequent commands will be ignored.
## Produced Metadata
## Example
INSERT `name`, `<timestamp>` into `sys.sys.databases`
Create all `<database>.sys` tables
## Exceptions
database already exists
# CREATE INDEX
This command creates an index over selected column(s) of an existing table.
```
<create-index> ::=
CREATE [ UNIQUE ] [ LOOK-UP | CLUSTERED ] INDEX <index>
ON [ <db-qualifer> ] <table>
( <column> [ ASC | DESC ] [ ,...n ] )
```
## Examples
```
CREATE INDEX ix_vendor-id ON product-vendor (vendor-id);
CREATE UNIQUE INDEX ix_vendor-id2 ON dbo.product-vendor
(vendor-id DESC, name ASC, address DESC);
CREATE INDEX ix_vendor-id3 ON purchasing..product-vendor (vendor-id);
```
## API
```
+$ create-index
$:
%create-index
name=@t
object-name=qualified-object :: because index can be over table or view
is-unique=?
is-clustered=?
columns=(list ordered-column)
==
```
## Arguments
**`UNIQUE`**
Specifies that no two rows are permitted to have the same index key value.
**`LOOK-UP | CLUSTERED`**
`CLUSTERED` creates an index in which the logical order of the key values determines the physical order of the corresponding rows in a table. A `<table>` or `<view>` can have only one clustered index at a time.
**`<index>`**
User-defined name for the new index. This name must follow the Hoon term naming standard.
**`<table>`**
Name of existing table the index targets.
If not explicitly qualified, defaults to the Obelisk agent's current database and 'dbo' namespace.
**`<column> [ ASC | DESC ] [ ,...n ] `**
List of column names in the target table. This list represents the sort hierarchy and optionally specifies the sort direction for each level. The default sorting is `ASC` (ascending).
## Remarks
This command mutates the state of the Obelisk agent.
Index names cannot start with 'pk-' or 'fk-' as these prefixes are reserved for primary keys and foreign keys respectively.
_NOTE_: Further investigation is required to determine how "clustering" works in Hoon.
## Produced Metadata
## Example
INSERT `table name`, `namespace` `index-name`, `LOOK-UP | CLUSTERED`, `is-unique`, `<timestamp>` into `<database>.sys.indices`
## Exceptions
index name already exists for table
table does not exist
column does not exist
UNIQUE specified and existing values are not unique for the column(s) specified
index name begins with 'pk-' or 'fk-'
# CREATE NAMESPACE
Namespaces group various database components, including tables and views. When not explicitly specified, namespace designations default to `dbo`.
```
<create-namespace> ::= CREATE NAMESPACE [<database>.]<namespace>
```
## Example
`CREATE NAMESPACE my-namespace`
## API
```
+$ create-namespace $:([%create-namespace database-name=@t name=@t])
```
## Arguments
**`<namespace>`**
This is a user-defined name for the new namespace. It must adhere to the hoon term naming standard.
Note: The "sys" namespace is reserved for system use.
## Remarks
This command mutates the state of the Obelisk agent.
## Produced Metadata
sys and data timestamps
## Example
INSERT `name`, `<timestamp>` into `<database>.sys.namespaces`
## Exceptions
namespace already exists
# CREATE PROCEDURE
Procedures are parameterized urQL scripts.
```
<create-proc> ::=
CREATE { PROC | PROCEDURE }
[<db-qualifer>]<procedure>
[ { #<parameter> <data-type> } ] [ ,...n ]
AS { <urql command>; | *hoon } [ ;...n ]
```
## Remarks
TBD
Cannot be used to create a database.
# CREATE TABLE
`<table>`s are the only means of indexed persistent `<table-sets>`s in Obelisk.
Any update to `<table>` contents results in a state change of the Obelisk agent.
_NOTE_: Further investigation is needed to understand if there's a reason to specify foreign key names (see CREATE INDEX).
```
<create-table> ::=
CREATE TABLE
[ <db-qualifer> ]<table>
( <column> <aura>
[ ,... n ] )
PRIMARY KEY [ CLUSTERED | LOOK-UP ] ( <column> [ ,... n ] )
[ { FOREIGN KEY <foreign-key> ( <column> [ ASC | DESC ] [ ,... n ] )
REFERENCES [ <namespace>. ] <table> ( <column> [ ,... n ] )
[ ON DELETE { NO ACTION | CASCADE | SET DEFAULT } ]
[ ON UPDATE { NO ACTION | CASCADE | SET DEFAULT } ] }
[ ,... n ] ]`
```
## API
```
+$ create-table
$:
%create-table
table=qualified-object
columns=(list column)
clustered=?
pri-indx=(list ordered-column)
foreign-keys=(list foreign-key)
==
```
## Arguments
**`<table>`**
This is a user-defined name for the new table. It must adhere to the hoon term naming standard.
If not explicitly qualified, it defaults to the Obelisk agent's current database and the 'dbo' namespace..
**`<column> <aura>`**
The list of user-defined column names and associated auras. Names must adhere to the hoon term naming standard.
For more details, refer to [ref-ch02-types](ref-ch02-types.md)
**`[ CLUSTERED | LOOK-UP ] ( <column> [ ,... n ]`**
These are column names in the required unique primary index. Defining the index as `LOOK-UP` is optional.
**`<foreign-key> ( <column> [ ASC | DESC ] [ ,... n ]`**
This is a user-defined name for `<foreign-key>`. It must adhere to the hoon term naming standard.
This list comprises column names in the table for association with a foreign table along with sort ordering. Default is `ASC` (ascending).
**`<table> ( <column> [ ,... n ]`**
Referenced foreign `<table>` and columns. Count and associated column auras must match the specified columns from the new `<table>` and comprise a `UNIQUE` index on the referenced foreign `<table>`.
**`ON DELETE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is deleted from the foreign table.
* NO ACTION (default)
The Obelisk agent raises an error and the delete action on the row in the parent foreign table is aborted.
* CASCADE
Corresponding rows are deleted from the referencing table when that row is deleted from the parent foreign table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is deleted.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
**`ON UPDATE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is updated in the foreign table.
* NO ACTION (default)
The Database Engine raises an error and the update action on the row in the parent table is aborted.
* CASCADE
Corresponding rows are updated in the referencing table when that row is updated in the parent table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is updated.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
## Remarks
This command mutates the state of the Obelisk agent.
`PRIMARY KEY` must be unique.
`FOREIGN KEY` constraints ensure data integrity for the data contained in the column or columns. They necessitate that each value in the column exists in the corresponding referenced column or columns in the referenced table. `FOREIGN KEY` constraints can only reference columns that are subject to a `PRIMARY KEY` or `UNIQUE INDEX` constraint in the referenced table.
NOTE: The specific definition of `CLUSTERED` in Hoon, possibly an ordered map, is to be determined during development.
## Produced Metadata
## Exceptions
name within namespace already exists for table
table referenced by FOREIGN KEY does not exist
table column referenced by FOREIGN KEY does not exist
aura mis-match in FOREIGN KEY
## Example
```
CREATE TABLE order-detail
(invoice-nbr @ud, line-item @ud, product-id @ud, special-offer-id @ud, message @t)
PRIMARY KEY CLUSTERED (invoice-nbr, line-item)
FOREIGN KEY fk-special-offer-order-detail (product-id, specialoffer-id)
REFERENCES special-offer (product-id, special-offer-id)
```
# CREATE TRIGGER
A trigger automatically runs when a specified table or view event occurs in the Obelisk agent. It runs a previously defined `<procedure>`.
An `INSTEAD OF` trigger fires before the triggering event can occur and replaces it. Otherwise the procedure runs after the triggering event succedes and all state changed by both the triggering event and trigger `<procedure>` is included in one and the same state change.
Triggering events are `INSERT`, `UPDATE`, and `DELETE` statements on a `<table>` and simple execution in the case of `<view>`.
```
<create-trigger> ::=
CREATE TRIGGER [ <db-qualifer> ]<trigger>
ON { <table> | <view> }
{ AFTER | INSTEAD OF }
{ [ INSERT ] [ , ] [ UPDATE ] [ , ] [ DELETE ] }
AS <procedure>
[ ENABLE | DISABLE ]
```
## Remarks
TBD
This command could be used to trigger any database process or agent.
# CREATE TYPE
TBD
`CREATE TYPE <type>`
# CREATE VIEW
A view creates a `<table-set>` whose contents (columns and rows) are defined by a `<transform>`.
The possibility of caching of views is TBD.
```
<create-view> ::=
CREATE VIEW [ <db-qualifer> ]<view> AS <transform>
```
## API
```
+$ create-view
$:
%create-view
view=qualified-object
query=transform
==
```
## Arguments
**`<view>`**
The user-defined name for the new view, which must adhere to the Hoon term naming standard.
**`<transform>`**
The `<transform>` that produces the output `<table-set>`.
## Remarks
This command mutates the state of the Obelisk agent.
Views are read only.
The final step of the `<transform>` must establish unique column names, whether inherited from prior `<table-set>`s or aliased columns.
Views cannot be defined on foreign ship databases.
## Produced Metadata
## Examples
INSERT `name`, `<transform>`, `<timestamp>` INTO `<database>.sys.views`
INSERT `name`, `<ordinal>`, `<column>` INTO `<database>.sys.view-columns`
## Exceptions
view already exists

View File

@ -1,284 +0,0 @@
# ALTER INDEX
Modifies the structure of an existing `<index>` on a user `<table>` or `<view>`.
```
<alter-index> ::=
ALTER [ UNIQUE ] [ NONCLUSTERED | CLUSTERED ] INDEX [ <db-qualifer> ]<index>
ON { <table> | <view> }
[ ( <column> [ ASC | DESC ] [ ,...n ] ) ]
{ DISABLE | RESUME}
```
## API
```
+$ alter-index
$:
%alter-index
name=qualified-object
object=qualified-object
columns=(list ordered-column)
action=index-action
==
```
## Arguments
**`UNIQUE`**
Specifies that no two rows are permitted to have the same index key value.
**`NONCLUSTERED | CLUSTERED`**
`CLUSTERED` creates an index in which the logical order of the key values determines the physical order of the corresponding rows in a table. A `<table>` or `<view>` can have only one clustered index at a time.
**`[ <db-qualifer> ]<index>`**
Specifies the target index.
**`<table> | <view>`**
Name of the underlying object of the index.
**`<column> [ ASC | DESC ] [ ,...n ] `**
List of column names in the target table. This list represents the sort hierarchy and optionally specifies the sort direction for each level. The default sorting is `ASC` (ascending).
**`DISABLE | RESUME`**
Used to disable an active index or resume a disabled index.
## Remarks
This command mutates the state of the Obelisk agent.
Cannot alter primary key and foreign key indices.
`RESUME` will rebuild the index if the underlying object is dirty.
Note: Further investigation into hoon ordered maps is needed to determine what exactly "clustered" means in hoon.
## Produced Metadata
update `<database>.sys.indices`
## Exceptions
index name does not exist for table
table does not exist
column does not exist
UNIQUE specified and existing values are not unique for the column(s) specified
# ALTER NAMESPACE
Transfer an existing user `<table>` or `<view>` to another `<namespace>`.
```
<alter-namespace> ::=
ALTER NAMESPACE [ <database>. ]<namespace>
TRANSFER { TABLE | VIEW } [ <db-qualifer> ]{ <table> | <view> }
```
## API
```
+$ alter-namespace
$:
%alter-namespace
database-name=@tas
source-namespace=@tas
object-type=object-type
target-namespace=@tas
target-name=@tas
==
```
## Arguments
**`<namespace>`**
Name of the target namespace into which the object is to be transferred.
**`TABLE | VIEW`**
Indicates the type of the target object.
**`<table> | <view>`**
Name of the object to be transferred to the target namespace..
## Remarks
This command mutates the state of the Obelisk agent.
Objects cannot be transferred in or out of namespace *sys*.
## Produced Metadata
update `<database>.sys.tables`
update `<database>.sys.views`
## Exceptions
namespace does not exist
`<table>` or `<view>` does not exist
# ALTER PROCEDURE
TBD
```
<alter-proc> ::=
ALTER { PROC | PROCEDURE }
[<db-qualifer>]<procedure>
[ { #<parameter> <data-type> } ] [ ,...n ]
AS { <urql command>; | *hoon } [ ;...n ]
```
# ALTER TABLE
Modify the columns and/or `<foreign-key>`s of an existing `<table>`.
```
<alter-> ::=
ALTER TABLE [ <db-qualifer> ]{ <table> }
{ ADD COLUMN ( <column> <aura> [ ,... n ] )
| ALTER COLUMN ( <column> <aura> [ ,... n ] )
| DROP COLUMN ( <column> [ ,... n ] )
| ADD FOREIGN KEY <foreign-key> (<column> [ ,... n ])
REFERENCES [<namespace>.]<table> (<column> [ ,... n ])
[ ON DELETE { NO ACTION | CASCADE } ]
[ ON UPDATE { NO ACTION | CASCADE } ]
[ ,... n ]
| DROP FOREIGN KEY ( <foreign-key> [ ,... n ] } )
```
Example:
```
ALTER TABLE my-table
DROP FOREIGN KEY fk-1, fk-2
```
## API
```
+$ alter-table
$:
%alter-table
table=qualified-object
alter-columns=(list column)
add-columns=(list column)
drop-columns=(list @tas)
add-foreign-keys=(list foreign-key)
drop-foreign-keys=(list @tas)
==
```
## Arguments
**`<table>`**
Name of `<table>` to alter.
**`ADD | ALTER COLUMN ( <column> <aura> [ ,... n ] )`**
Denotes a list of user-defined column names and associated auras. `ALTER` is used to change the aura of an existing column.
Names must follow the Hoon term naming standard. See [ref-ch02-types](ref-ch02-types.md)
**`DROP COLUMN ( <column> [ ,... n ] )`**
Denotes a list of existing column names to delete from the `<table>` structure.
**`[ NONCLUSTERED | CLUSTERED ] ( <column> [ ,... n ]`**
These are column names in the required unique primary index. Defining the index as `CLUSTERED` is optional.
**`ADD | DROP`**
The action is to add or drop a foreign key.
**`<foreign-key> ( <column> [ ASC | DESC ] [ ,... n ]`**
This is a user-defined name for `<foreign-key>`. It must adhere to the hoon term naming standard.
This list comprises column names in the table for association with a foreign table along with sort ordering. Default is `ASC` (ascending).
**`<table> ( <column> [ ,... n ]`**
Referenced foreign `<table>` and columns. Count and associated column auras must match the specified columns from the new `<table>` and comprise a `UNIQUE` index on the referenced foreign `<table>`.
**`ON DELETE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is deleted from the foreign table.
* NO ACTION (default)
The Obelisk agent raises an error and the delete action on the row in the parent foreign table is aborted.
* CASCADE
Corresponding rows are deleted from the referencing table when that row is deleted from the parent foreign table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is deleted.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
**`ON UPDATE { NO ACTION | CASCADE | SET DEFAULT }`**
This argument specifies the action to be taken on the rows in the table that have a referential relationship when the referenced row is updated in the foreign table.
* NO ACTION (default)
The Database Engine raises an error and the update action on the row in the parent table is aborted.
* CASCADE
Corresponding rows are updated in the referencing table when that row is updated in the parent table.
* SET DEFAULT
All the values that make up the foreign key in the referencing row(s) are set to their bunt (default) values when the corresponding row in the parent foreign table is updated.
The Obelisk agent raises an error if the parent foreign table has no entry with bunt values.
## Remarks
This command mutates the state of the Obelisk agent.
`FOREIGN KEY` constraints ensure data integrity for the data contained in the column or columns. They necessitate that each value in the column exists in the corresponding referenced column or columns in the referenced table. `FOREIGN KEY` constraints can only reference columns that are subject to a `PRIMARY KEY` or `UNIQUE INDEX` constraint in the referenced table.
## Produced Metadata
update `<database>.sys.table-columns`
update `<database>.sys.table-columns`
update `<database>.sys.table-ref-integrity`
## Exceptions
alter a column that does not exist
add a column that does exist
drop a column that does not exist
table referenced by FOREIGN KEY does not exist
table column referenced by FOREIGN KEY does not exist
aura mis-match in FOREIGN KEY
# ALTER TRIGGER
TBD
```
<alter-trigger> ::=
ALTER TRIGGER { [ <db-qualifer> ]{ <trigger> } | ALL }
ON { SERVER | <database.name> | <table> | <view> }
[ ENABLE | DISABLE ]
```
# ALTER VIEW
Alter the structure of an existing `<view>`.
```
<alter-view> ::=
ALTER VIEW [ <db-qualifer> ]{ <view> }
( { [<alias>.] <column> } [ ,...n ] )
AS <select_statement>
```
## API
```
+$ alter-view
$:
%alter-view
view=qualified-object
transform
==
```
## Arguments
**`<view>`**
Specifies the name of the view to alter.
**`<transform>`**
Refers to the `<transform>` producing the output `<table-set>`.
## Remarks
This command mutates the state of the Obelisk agent.
## Produced Metadata
UPDATE `<database>.sys.views`
UPDATE `<database>.sys.view-columns`
## Exceptions
view does not exist.

View File

@ -1,227 +0,0 @@
# DROP DATABASE
Deletes an existing `<database>` and all associated objects.
```
<drop-database> ::= DROP DATABASE [ FORCE ] <database>
```
## API
```
+$ drop-database
$:
%drop-database
name=@tas
force=?
==
```
## Arguments
**`FORCE`**
Optionally, force deletion of a database.
**`<database>`**
The name of the database to delete.
## Remarks
This command mutates the state of the Obelisk agent.
The command only succeeds when no populated tables exist in the database, unless `FORCE` is specified.
## Produced Metadata
DELETE row from `sys.sys.databases`.
## Exceptions
`<database>` does not exist.
`<database>` has populated tables and FORCE was not specified.
# DROP INDEX
Deletes an existing `<index>`.
```
<drop-index> ::=
DROP INDEX <index>
ON [ <db-qualifer> ] { <table> | <view> }
```
## API
```
+$ drop-index
$:
%drop-index
name=@tas
object=qualified-object
==
```
## Arguments
**`<index>`**
The name of the index to delete.
**`<table> | <view>`**
`<table>` or `<view>` with the named index.
## Remarks
This command mutates the state of the Obelisk agent.
Indexes with names that begin with "pk-" cannot be dropped, as these are table primary keys.
This command can be used to delete a `<foreign-key>`.
If `<view>` is shadowing `<table>`, the system attempts to find `<index>` on `<view>` first, then `<table>`.
## Produced Metadata
DELETE FROM `<database>.sys.indices`
DELETE FROM `<database>.sys.table-ref-integrity`
## Exceptions
`<table>` or `<view>` does not exist
`<index>` does not exist on `<table>` or `<view>`.
# DROP NAMESPACE
Deletes a `<namespace>` and all its associated objects.
```
<drop-namespace> ::=
DROP NAMESPACE [ FORCE ] [ <database>. ]<namespace>
```
## API
```
+$ drop-namespace
$:
%drop-namespace
database-name=@tas
name=@tas
force=?
==
```
## Arguments
**`FORCE`**
Optionally, force deletion of `<namespace>`.
**`<namespace>`**
The name of `<namespace>` to delete.
## Remarks
This command mutates the state of the Obelisk agent.
Only succeeds when no *populated* `<table>`s are in the namespace, unless `FORCE` is specified, possibly resulting in cascading object drops described in `DROP TABLE`.
The namespaces *dbo* and *sys* cannot be dropped.
## Produced Metadata
DELETE row from `<database>.sys.namespaces`.
## Exceptions
`<namespace>` does not exist.
`<namespace>` has populated tables and FORCE was not specified.
# DROP TABLE
Deletes a `<table>` and all associated objects
```
<drop-table> ::= DROP TABLE [ FORCE ] [ <db-qualifer> ]{ <table> }
```
## API
```
+$ drop-table
$:
%drop-table
table=qualified-object
force=?
==
```
## Arguments
**`FORCE`**
Optionally, force deletion of a table.
**`<table>`**
Name of `<table>` to delete.
## Remarks
This command mutates the state of the Obelisk agent.
Cannot drop if used in a view or foreign key, unless `FORCE` is specified, resulting in cascading object drops.
Cannot drop when the `<table>` is populated unless `FORCE` is specified.
## Produced Metadata
DELETE from `<database>.sys.tables`.
DELETE from `<database>.sys.views`.
DELETE from `<database>.sys.indices`.
## Exceptions
`<table>` does not exist.
`<table>` is populated and FORCE was not specified.
`<table>` used in `<view>` and FORCE was not specified.
`<table>` used in `<foreign-key>` and FORCE was not specified.
# DROP TRIGGER
TBD
```
<drop-trigger> ::=
DROP TRIGGER [ <db-qualifer> ]{ <trigger> }
ON { <table> | <view> }
```
# DROP TYPE
TBD
`DROP TYPE <type>`
## Remarks
Cannot drop if type-name is in use.
# DROP VIEW
```
<drop-view> ::= DROP VIEW [ FORCE ] [ <db-qualifer> ]<view>
```
## API
```
+$ drop-view
$:
%drop-view
view=qualified-object
force=?
==
```
## Arguments
**`FORCE`**
Force delete of `<view>`.
**`<view>`**
Name of `<view>` to delete.
## Remarks
This command mutates the state of the Obelisk agent.
Views that are in use in another view cannot be dropped unless `FORCE` is specified, which may result in cascading object drops.
## Produced Metadata
DELETE from `<database>.sys.views`.
## Exceptions
`<view>` does not exist.
`<view>` is in use by other `<view>` and FORCE was not specified.

View File

@ -91,7 +91,7 @@
script q.q.u.+3.q:namespace-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(alter-namespace:ast %alter-namespace -<.parsed ->.parsed +<.parsed +>+>+<.parsed +>+>+>.parsed) commands]
[`command:ast`(alter-namespace:ast %alter-namespace -<.parsed ->.parsed +<.parsed +>+>+<.parsed +>+>+>.parsed ~) commands]
==
%alter-table
~| "alter table error: {<(scag 100 q.q.command-nail)>} ..."
@ -102,35 +102,35 @@
script q.q.u.+3.q:table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(alter-table:ast %alter-table -.parsed +>.parsed ~ ~ ~ ~) commands]
[`command:ast`(alter-table:ast %alter-table -.parsed +>.parsed ~ ~ ~ ~ ~) commands]
==
?: =(+<.parsed %add-column)
%= $
script q.q.u.+3.q:table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(alter-table:ast %alter-table -.parsed ~ +>.parsed ~ ~ ~) commands]
[`command:ast`(alter-table:ast %alter-table -.parsed ~ +>.parsed ~ ~ ~ ~) commands]
==
?: =(+<.parsed %drop-column)
%= $
script q.q.u.+3.q:table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ +>.parsed ~ ~) commands]
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ +>.parsed ~ ~ ~) commands]
==
?: =(+<.parsed %add-fk)
%= $
script q.q.u.+3.q:table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ (build-foreign-keys [-.parsed +>.parsed]) ~) commands]
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ (build-foreign-keys [-.parsed +>.parsed]) ~ ~) commands]
==
?: =(+<.parsed %drop-fk)
%= $
script q.q.u.+3.q:table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +>.parsed) commands]
[`command:ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +>.parsed ~) commands]
==
~|("Cannot parse table {<p.q.command-nail>}" !!)
%create-database
@ -140,7 +140,7 @@
%= $
script ""
commands
[`command:ast`(create-database:ast %create-database p.u.+3:q.+3:(parse-face [[1 1] q.q.command-nail])) commands]
[`command:ast`(create-database:ast %create-database p.u.+3:q.+3:(parse-face [[1 1] q.q.command-nail]) ~) commands]
==
%create-index
~| "create index error: {<(scag 100 q.q.command-nail)>} ..."
@ -201,12 +201,12 @@
%= $
script q.q.u.+3.q:create-namespace-nail
displacement (sub script-length (lent script))
commands [`command:ast`(create-namespace:ast %create-namespace default-database parsed) commands]
commands [`command:ast`(create-namespace:ast %create-namespace default-database parsed ~) commands]
==
%= $
script q.q.u.+3.q:create-namespace-nail
displacement (sub script-length (lent script))
commands [`command:ast`(create-namespace:ast %create-namespace -.parsed +.parsed) commands]
commands [`command:ast`(create-namespace:ast %create-namespace -.parsed +.parsed ~) commands]
==
%create-table
~| "create table error: {<(scag 100 q.q.command-nail)>} ..."
@ -217,13 +217,13 @@
script q.q.u.+3.q:table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(create-table:ast %create-table -.parsed +<.parsed +>+<.parsed +>+>.parsed ~) commands]
[`command:ast`(create-table:ast %create-table -.parsed +<.parsed +>+<.parsed +>+>.parsed ~ ~) commands]
==
%= $
script q.q.u.+3.q:table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(create-table:ast %create-table -.parsed +<.parsed +>->-.parsed +>->+.parsed (build-foreign-keys [-.parsed +>+.parsed])) commands]
[`command:ast`(create-table:ast %create-table -.parsed +<.parsed +>->-.parsed +>->+.parsed (build-foreign-keys [-.parsed +>+.parsed]) ~) commands]
==
%create-view
~| "create view error: {<(scag 100 q.q.command-nail)>} ..."
@ -273,26 +273,26 @@
%= $
script q.q.u.+3.q:drop-namespace-nail
displacement (sub script-length (lent script))
commands [`command:ast`(drop-namespace:ast %drop-namespace default-database parsed %.n) commands]
commands [`command:ast`(drop-namespace:ast %drop-namespace default-database parsed %.n ~) commands]
==
?: ?=([@ @] parsed) :: force name
?: =(%force -.parsed)
%= $
script q.q.u.+3.q:drop-namespace-nail
displacement (sub script-length (lent script))
commands [`command:ast`(drop-namespace:ast %drop-namespace default-database +.parsed %.y) commands]
commands [`command:ast`(drop-namespace:ast %drop-namespace default-database +.parsed %.y ~) commands]
==
%= $ :: db.name
script q.q.u.+3.q:drop-namespace-nail
displacement (sub script-length (lent script))
commands [`command:ast`(drop-namespace:ast %drop-namespace -.parsed +.parsed %.n) commands]
commands [`command:ast`(drop-namespace:ast %drop-namespace -.parsed +.parsed %.n ~) commands]
==
~| "Cannot parse drop-namespace {<parsed>}"
?: ?=([* [@ @]] parsed) :: force db.name
%= $
script q.q.u.+3.q:drop-namespace-nail
displacement (sub script-length (lent script))
commands [`command:ast`(drop-namespace:ast %drop-namespace +<.parsed +>.parsed %.y) commands]
commands [`command:ast`(drop-namespace:ast %drop-namespace +<.parsed +>.parsed %.y ~) commands]
==
!!
%drop-table
@ -304,14 +304,14 @@
script q.q.u.+3.q:drop-table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(drop-table:ast %drop-table +.parsed %.y) commands]
[`command:ast`(drop-table:ast %drop-table +.parsed %.y ~) commands]
==
?: ?=([@ @ @ @ @] parsed) :: qualified table name
%= $
script q.q.u.+3.q:drop-table-nail
displacement (sub script-length (lent script))
commands
[`command:ast`(drop-table:ast %drop-table parsed %.n) commands]
[`command:ast`(drop-table:ast %drop-table parsed %.n ~) commands]
==
~|("Cannot parse drop-table {<parsed>}" !!)
%drop-view

View File

@ -327,7 +327,7 @@
::
::
:: $create-database: $:([%create-database name=@tas])
+$ create-database $:([%create-database name=@tas])
+$ create-database $:([%create-database name=@tas as-of=(unit @da)])
::
:: $create-index:
+$ create-index
@ -340,18 +340,23 @@
columns=(list ordered-column)
==
::
:: $create-namespace: $:([%create-namespace database-name=@tas name=@tas])
+$ create-namespace $:([%create-namespace database-name=@tas name=@tas])
:: $create-namespace
+$ create-namespace
$: %create-namespace
database-name=@tas
name=@tas
as-of=(unit @da)
==
::
:: $create-table:
:: $create-table
+$ create-table
$:
%create-table
$: %create-table
table=qualified-object
columns=(list column)
clustered=?
pri-indx=(list ordered-column)
foreign-keys=(list foreign-key)
as-of=(unit @da)
==
::
:: $create-trigger: TBD
@ -389,14 +394,14 @@
::
:: $drop-namespace: database-name=@tas name=@tas force=?
+$ drop-namespace
$:([%drop-namespace database-name=@tas name=@tas force=?])
$:([%drop-namespace database-name=@tas name=@tas force=? as-of=(unit @da)])
::
:: $drop-table: table=qualified-object force=?
+$ drop-table
$:
%drop-table
$: %drop-table
table=qualified-object
force=?
as-of=(unit @da)
==
::
:: $drop-trigger: TBD
@ -433,13 +438,13 @@
::
:: $alter-namespace: move an object from one namespace to another
+$ alter-namespace
$:
%alter-namespace
$: %alter-namespace
database-name=@tas
source-namespace=@tas
object-type=object-type
target-namespace=@tas
target-name=@tas
as-of=(unit @da)
==
::
:: $alter-table: to do - this could be simpler
@ -452,6 +457,7 @@
drop-columns=(list @tas)
add-foreign-keys=(list foreign-key)
drop-foreign-keys=(list @tas)
as-of=(unit @da)
==
::
:: $alter-trigger: TBD

View File

@ -1 +1 @@
[%zuse 413]
[%zuse 412]

View File

@ -3,63 +3,12 @@
|%
++ foo-table [%qualified-object ship=~ database='db1' namespace='dbo' name='foo']
++ column-foo [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='foo'] column='foo' alias=~]
++ column-bar [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='bar'] column='bar' alias=~]
++ all-columns [%qualified-object ship=~ database='ALL' namespace='ALL' name='ALL']
++ select-all-columns [%select top=~ bottom=~ distinct=%.n columns=~[all-columns]]
++ cte-t1 [%cte name='t1' [%query ~ scalars=~ predicate=~ group-by=~ having=~ selection=select-all-columns ~]]
++ foo-table-row [%query-row ~['col1' 'col2' 'col3']]
++ delete-pred `[%eq [column-foo ~ ~] [column-bar ~ ~]]
++ predicate-bar-eq-bar
[%eq [[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='tgt'] column='bar' alias=~] ~ ~] [[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='bar' alias=~] ~ ~]]
++ cte-bar-foobar
[%cte name='T1' %query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ distinct=%.n columns=~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='bar'] column='bar' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='foobar'] column='foobar' alias=~]]] order-by=~]
++ cte-bar-foobar-src
[%cte name='src' %query from=~ scalars=~ predicate=~ group-by=~ having=~ selection=[%select top=~ bottom=~ distinct=%.n columns=~[[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='bar'] column='bar' alias=~] [%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='foobar'] column='foobar' alias=~]]] order-by=~]
++ column-src-foo
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='foo' alias=~]
++ column-src-bar
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='bar' alias=~]
++ column-src-foobar
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN' name='src'] column='foobar' alias=~]
++ passthru-tgt
[%table-set object=[%query-row ~['col1' 'col2' 'col3']] alias=[~ 'tgt']]
++ passthru-src
[%table-set object=[%query-row ~['col1' 'col2' 'col3']] alias=[~ 'src']]
++ col1
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='col1'] column='col1' alias=~]
++ col2
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='col2'] column='col2' alias=~]
++ col3
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='col3'] column='col3' alias=~]
++ col4
[%qualified-column qualifier=[%qualified-object ship=~ database='UNKNOWN' namespace='COLUMN-OR-CTE' name='col4'] column='col4' alias=~]
++ cte-bar
[%cte name='bar' [%query [~ [%from object=[%table-set object=[%qualified-object ship=~ database='db1' namespace='dbo' name='bar'] alias=~] joins=~]] scalars=~ `[%eq [col1 ~ ~] [col2 ~ ~]] group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=~[col2]] ~]]
++ cte-foobar
[%cte name='foobar' [%query [~ [%from object=[%table-set object=[%qualified-object ship=~ database='db1' namespace='dbo' name='foobar'] alias=~] joins=~]] scalars=~ `[%eq [col1 ~ ~] [[value-type=%ud value=2] ~ ~]] group-by=~ having=~ [%select top=~ bottom=~ distinct=%.n columns=~[col3 col4]] ~]]
++ one-eq-1 [%eq [literal-1 ~ ~] [literal-1 ~ ~]]
++ literal-1 [value-type=%ud value=1]
++ passthru-unaliased [%table-set object=[%query-row ~['col1' 'col2' 'col3']] alias=~]
++ update-pred
[%and one-eq-1 [%eq [col2 ~ ~] [[value-type=%ud value=4] ~ ~]]]
++ test-update-04
++ test-create-namespace-1
=/ expected1 [%create-namespace database-name='other-db' name='my-namespace' as-of=~]
=/ expected2 [%create-namespace database-name='my-db' name='another-namespace' as-of=~]
%+ expect-eq
!> ~[[%transform ctes=~[cte-t1] [[%update table=foo-table columns=~['col3' 'col1'] values=~[[value-type=%t value='hello'] col2] predicate=`update-pred] ~ ~]]]
!> (parse:parse(current-database 'db1') "with (select *) as t1 update foo set col1=col2, col3 = 'hello' where 1 = 1 and col2 = 4")
::
:: update with three ctes and predicate
++ test-update-05
%+ expect-eq
!> ~[[%transform ctes=~[cte-t1 cte-foobar cte-bar] [[%update table=foo-table columns=~['col3' 'col1'] values=~[[value-type=%t value='hello'] col2] predicate=`update-pred] ~ ~]]]
!> (parse:parse(current-database 'db1') "with (select *) as t1, (from foobar where col1=2 select col3, col4) as foobar, (from bar where col1=col2 select col2) as bar update foo set col1=col2, col3 = 'hello' where 1 = 1 and col2 = 4")
!> ~[expected1 expected2]
!> (parse:parse(default-database 'other-db') "cReate\0d\09 namespace my-namespace ; cReate namesPace my-db.another-namespace")
::@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

View File

@ -67,15 +67,15 @@
::
:: 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']
=/ expected1 [%alter-namespace database-name='db' source-namespace='ns' object-type=%table target-namespace='ns2' target-name='table' as-of=~]
=/ expected2 [%alter-namespace database-name='db1' source-namespace='ns' object-type=%table target-namespace='dbo' target-name='table' as-of=~]
%+ expect-eq
!> ~[expected1 expected2]
!> (parse:parse(default-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 [%alter-namespace database-name='db1' source-namespace='ns' object-type=%table target-namespace='dbo' target-name='table' as-of=~] %+ expect-eq
!> ~[expected]
!> (parse:parse(default-database 'db1') "ALTER NAMESPACE ns TRANSFER TABLE table ")
::
@ -95,43 +95,43 @@
:: 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
=/ 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=~]
=/ 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=~]
=/ 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 '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
=/ 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=~]
=/ 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
=/ 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=~]
=/ 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
=/ 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=~]
=/ 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
=/ 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=~]
=/ 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
=/ 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=~]
=/ 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
!> ~[expected]
@ -139,21 +139,21 @@
::
:: drop 2 foreign keys, extra spaces
++ test-alter-table-7
=/ 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' ~]]
=/ 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
=/ 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' ~]]
=/ 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
=/ 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' ~]]
=/ 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)")
@ -168,13 +168,13 @@
:: tests 1, 3, and extra whitespace characters
++ test-create-database-1
%+ expect-eq
!> ~[[%create-database name='my-database']]
!> ~[[%create-database name='my-database' as-of=~]]
!> (parse:parse(default-database 'dummy') "cReate datAbase \0a my-database ")
::
:: subsequent commands ignored
++ test-create-database-2
%+ expect-eq
!> ~[[%create-database name='my-database']]
!> ~[[%create-database name='my-database' as-of=~]]
!> (parse:parse(default-database 'dummy') "cReate datAbase \0a my-database; cReate namesPace my-db.another-namespace")
::
:: fail when database name is not a term
@ -244,8 +244,8 @@
::
:: tests 1, 2, 3, 5, and extra whitespace characters
++ test-create-namespace-1
=/ expected1 [%create-namespace database-name='other-db' name='my-namespace']
=/ expected2 [%create-namespace database-name='my-db' name='another-namespace']
=/ expected1 [%create-namespace database-name='other-db' name='my-namespace' as-of=~]
=/ expected2 [%create-namespace database-name='my-db' name='another-namespace' as-of=~]
%+ expect-eq
!> ~[expected1 expected2]
!> (parse:parse(default-database 'other-db') "cReate\0d\09 namespace my-namespace ; cReate namesPace my-db.another-namespace")
@ -253,7 +253,7 @@
:: leading and trailing whitespace characters, end delimiter not required on single
++ test-create-namespace-2
%+ expect-eq
!> ~[[%create-namespace database-name='other-db' name='my-namespace']]
!> ~[[%create-namespace database-name='other-db' name='my-namespace' as-of=~]]
!> (parse:parse(default-database 'other-db') " \09cReate\0d\09 namespace my-namespace ")
::
:: fail when database qualifier is not a term
@ -270,8 +270,8 @@
::
:: tests 1, 2, 3, 5, and extra whitespace characters, db.ns.table clustered on delete cascade on update cascade; db..table look-up on update cascade on delete cascade
++ test-create-table-1
=/ expected1 [%create-table table=[%qualified-object ship=~ database='db' namespace='ns' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db' namespace='ns' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db' namespace='dbo' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade %update-cascade]]]]
=/ expected2 [%create-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.n pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db' namespace='dbo' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade %update-cascade]]]]
=/ expected1 [%create-table table=[%qualified-object ship=~ database='db' namespace='ns' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db' namespace='ns' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db' namespace='dbo' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade %update-cascade]]] as-of=~]
=/ expected2 [%create-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.n pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db' namespace='dbo' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade %update-cascade]]] as-of=~]
=/ urql1 "crEate taBle db.ns.my-table ( col1 @t , col2 @p , col3 @ud ) pRimary kEy clusTered ( col1 , col2 ) foReign KeY fk ( col1 , col2 desc ) reFerences fk-table ( col19 , col20 ) On dELETE CAsCADE oN UPdATE CAScADE "
=/ urql2 "crEate taBle db..my-table ( col1 @t , col2 @p , col3 @ud ) pRimary kEy look-up ( col1 , col2 ) foReign KeY fk ( col1 , col2 desc ) reFerences fk-table ( col19 , col20 ) On UPdATE CAsCADE oN dELETE CAScADE "
%+ expect-eq
@ -280,7 +280,7 @@
::
:: leading whitespace characters, whitespace after end delimiter, create look-up table... table ... references ns.fk-table on update no action on delete no action
++ test-create-table-2
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.n pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='ns' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~]]]
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.n pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='ns' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~]] as-of=~]
=/ urql2 " \0acreate table my-table (col1 @t,col2 @p,col3 @ud) primary key look-up (col1, col2) foreign key fk (col1,col2 desc) reFerences ns.fk-table (col19, col20) on update no action on delete no action; "
%+ expect-eq
!> ~[expected]
@ -288,7 +288,7 @@
::
:: create table... table ... references ns.fk-table on update no action on delete cascade
++ test-create-table-3
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='ns' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade]]]]
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='ns' name='fk-table'] reference-columns=~['col19' 'col20'] referential-integrity=~[%delete-cascade]]] as-of=~]
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1, col2) foreign key fk (col1,col2 desc) reFerences ns.fk-table (col19, col20) on update no action on delete cascade"
%+ expect-eq
!> ~[expected]
@ -296,7 +296,7 @@
::
:: create table... table ... references fk-table on update cascade on delete no action
++ test-create-table-4
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-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=~[%update-cascade]]]]
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-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=~[%update-cascade]]] as-of=~]
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1, col2) foreign key fk (col1,col2 desc) reFerences fk-table (col19, col20) on update cascade on delete no action"
%+ expect-eq
!> ~[expected]
@ -304,7 +304,7 @@
::
:: create table... table ... single column indices... references fk-table on update cascade
++ test-create-table-5
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=~['col20'] referential-integrity=~[%update-cascade]]]]
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=~['col20'] referential-integrity=~[%update-cascade]]] as-of=~]
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences fk-table (col20) on update cascade"
%+ expect-eq
!> ~[expected]
@ -312,7 +312,7 @@
::
:: create table... table ... single column indices... references fk-table
++ test-create-table-6
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=~['col20'] referential-integrity=~]]]
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=~['col20'] referential-integrity=~]] as-of=~]
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences fk-table (col20) "
%+ expect-eq
!> ~[expected]
@ -320,7 +320,7 @@
::
:: create table... no foreign key
++ test-create-table-7
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~]
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y] [%ordered-column name='col2' is-ascending=%.y]] foreign-keys=~ as-of=~]
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1,col2)"
%+ expect-eq
!> ~[expected]
@ -328,7 +328,7 @@
::
:: create table... 2 foreign keys
++ test-create-table-8
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=['col20' ~] referential-integrity=~] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-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=~]]]
=/ expected [%create-table table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%column name='col1' column-type=%t] [%column name='col2' column-type=%p] [%column name='col3' column-type=%ud]] clustered=%.y pri-indx=~[[%ordered-column name='col1' is-ascending=%.y]] foreign-keys=~[[%foreign-key name='fk' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-table'] columns=~[[%ordered-column name='col2' is-ascending=%.n]] reference-table=[%qualified-object ship=~ database='db1' namespace='dbo' name='fk-table'] reference-columns=['col20' ~] referential-integrity=~] [%foreign-key name='fk2' table=[%qualified-object ship=~ database='db1' namespace='dbo' name='my-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=~]] as-of=~]
=/ urql "create table my-table (col1 @t,col2 @p,col3 @ud) primary key (col1) foreign key fk (col2 desc) reFerences fk-table (col20), fk2 (col1, col2 desc) reFerences fk-table2 (col19, col20)"
%+ expect-eq
!> ~[expected]
@ -476,8 +476,8 @@
::
:: tests 1, 2, 3, 5, and extra whitespace characters, force db.name, name
++ test-drop-namespace-1
=/ expected1 [%drop-namespace database-name='db' name='name' force=%.n]
=/ expected2 [%drop-namespace database-name='other-db' name='name' force=%.y]
=/ expected1 [%drop-namespace database-name='db' name='name' force=%.n as-of=~]
=/ expected2 [%drop-namespace database-name='other-db' name='name' force=%.y as-of=~]
%+ expect-eq
!> ~[expected1 expected2]
!> (parse:parse(default-database 'other-db') "droP Namespace db.name;droP \0d\09 Namespace FORce \0a name")
@ -485,13 +485,13 @@
:: leading and trailing whitespace characters, end delimiter not required on single, force name
++ test-drop-namespace-2
%+ expect-eq
!> ~[[%drop-namespace database-name='other-db' name='name' force=%.y]]
!> ~[[%drop-namespace database-name='other-db' name='name' force=%.y as-of=~]]
!> (parse:parse(default-database 'other-db') " \09drOp\0d\09 naMespace\0a force name ")
::
:: db.name
++ test-drop-namespace-3
%+ expect-eq
!> ~[[%drop-namespace database-name='db' name='name' force=%.n]]
!> ~[[%drop-namespace database-name='db' name='name' force=%.n as-of=~]]
!> (parse:parse(default-database 'other-db') "drop namespace db.name")
::
:: fail when database qualifier is not a term
@ -508,8 +508,8 @@
::
:: tests 1, 2, 3, 5, and extra whitespace characters
++ test-drop-table-1
=/ expected1 [%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.y]
=/ expected2 [%drop-table table=[%qualified-object ship=~ database='db' namespace='ns' name='name'] force=%.n]
=/ 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=~]
%+ expect-eq
!> ~[expected1 expected2]
!> (parse:parse(default-database 'other-db') "droP table FORce db.ns.name;droP table \0a db.ns.name")
@ -517,37 +517,37 @@
:: leading and trailing whitespace characters, end delimiter not required on single, force db..name
++ test-drop-table-2
%+ expect-eq
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.y]]
!> ~[[%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 ")
::
:: db..name
++ test-drop-table-3
%+ expect-eq
!> ~[[%drop-table table=[%qualified-object ship=~ database='db' namespace='dbo' name='name'] force=%.n]]
!> ~[[%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")
::
:: force ns.name
++ test-drop-table-4
%+ expect-eq
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.y]]
!> ~[[%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")
::
:: ns.name
++ test-drop-table-5
%+ expect-eq
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='ns' name='name'] force=%.n]]
!> ~[[%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")
::
:: force name
++ test-drop-table-6
%+ expect-eq
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.y]]
!> ~[[%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")
::
:: name
++ test-drop-table-7
%+ expect-eq
!> ~[[%drop-table table=[%qualified-object ship=~ database='other-db' namespace='dbo' name='name'] force=%.n]]
!> ~[[%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")
::
:: fail when database qualifier is not a term