Use IndexColumn
in all index definitions
#1900
Merged
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.
Index column lists generally allow for more flexibility than just column names: i.e.
ASC
/DESC
modifiers, Postgres opclasses, MySQL column prefix length, and generic expressions/"functional key parts".This change uses the existing support for these constructs added in #1707 for
CREATE INDEX
and changes the AST forALTER TABLE <table> ADD KEY
(and associated variants), and constraints present inCREATE TABLE
statements to support these constructs in those location.Note that, as was already the case with existing
CREATE INDEX
support, there is no special representation for MySQL column prefix length (INDEX (textcol(10))
), nor do we require the enclosing parentheses for MySQL functional key parts (INDEX ((col1 + col2))
; for Postgres, this is optional if it doesn't introduce ambiguity). Instead, these are parsed generically as expressions, so the former is parsed as a function call and the latter is wrapped inExpr::Nested
.Also note that, as far as I can tell, no dialect supports these more general column expressions in the case of
FOREIGN KEY
constraints, so the parsing and AST for foreign keys are left unchanged.