Update sql.bnf to add create statement overrides for use the schema create #646
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add
CREATE
stubs that can be overridden in dialects where needed to order statementsSqlDelight TreeUtil
forInitializationStatements
is responsible for ordering the sql statements whenschema.create
is generated - https://github.com/cashapp/sqldelight/blob/d7cc00eabc133b43f38a1e75f70af7e786dd00d7/sqldelight-compiler/src/main/kotlin/app/cash/sqldelight/core/lang/util/TreeUtil.kt#L255Note:- Migrations don't use this ordering and is preferred way of creating more complex schema
Currently
CREATE TABLE
statements are ordered first - some database supportCREATE
statements that execute before e.gCREATE SCHEMA sales
needs to be run beforeCREATE TABLE sales.Orders
What an updated TreeUtil would look like using the overrides of create statements that may be available
e.g Postgresql.bnf would override
create_schema_stmt
with the dialect implementation and TreeUtil would be able to use the statements