You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Some dialects support compound DDL statements, where a single statement changes multiple things atomically. For example:
-- Various dialects support adding multiple columns in one go.-- There are different syntaxes for this, here's one possible syntax:ALTERTABLE t
ADD col1 INT,
ADD col2 INT-- MySQL supports adding comments with columns and tables directly:CREATETABLEt (
i INT COMMENT 'column comment'
) COMMENT 'table comment';
It would be useful to be able to decompose a query into multiple queries to result in this:
ALTERTABLE t ADD col1 INT;
ALTERTABLE t ADD col2 INT;
CREATETABLEt (i INT);
COMMENT ON TABLE t IS 'table comment';
COMMENT ON COLUMN t.i IS 'column comment';
While the original dialect may not be able to run the decomposed queries, the decomposition is still very useful in use-cases like the DDLDatabase, see #12779.
The API of decomposing queries is part of the commercial SQL transformation feature set, but the implementation for this feature should be offered also in the OSS edition to benefit the OSS version of the DDLDatabase.
The operation is not very important, so putting it on the ubiquitous Query type generates "API noise". Since it is a SQL transformation, which is best implemented using QueryPart::$replace, it's probably more interesting to place this in a new Replacers type.
lukaseder
changed the title
Add Query.decompose(): Queries to decompose a compound statement into equivalent individual statements
Add Replacers.decompose(): Replacer to decompose a compound statement into equivalent individual statements
Feb 7, 2022
lukaseder
changed the title
Add Replacers.decompose(): Replacer to decompose a compound statement into equivalent individual statements
Add Replacers.decomposing(): Replacer to decompose a compound statement into equivalent individual statements
Feb 7, 2022
Some dialects support compound DDL statements, where a single statement changes multiple things atomically. For example:
It would be useful to be able to decompose a query into multiple queries to result in this:
While the original dialect may not be able to run the decomposed queries, the decomposition is still very useful in use-cases like the
DDLDatabase
, see #12779.The API of decomposing queries is part of the commercial SQL transformation feature set, but the implementation for this feature should be offered also in the OSS edition to benefit the OSS version of the
DDLDatabase
.This feature is part of a bigger task, see #9645
Decompositions implemented so far:
COMMENT
toCOMMENT ON COLUMN
CREATE TABLE
In(will be done later)ALTER TABLE
COMMENT
toCOMMENT ON TABLE
INDEX
definition toCREATE INDEX
Decompositions to be considered (perhaps using some configuration, similar to the
DDLExportConfiguration
)?:Inline constraint specifications towon't be done for now)ALTER TABLE .. ADD CONSTRAINT
(turned off by default)Decompositions that won't be considered:
CREATE TABLE .. (col1, col2)
toCREATE TABLE .. (col1); ALTER TABLE .. ADD col2
See also:
The text was updated successfully, but these errors were encountered: