Repository navigation
feat(dialect): add index prefix length hook - #407
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #407 +/- ##
==========================================
+ Coverage 92.98% 92.99% +0.01%
==========================================
Files 275 275
Lines 39360 39538 +178
==========================================
+ Hits 36598 36768 +170
- Misses 2762 2770 +8
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
cursor
Bot
force-pushed
the
upstream/dialect-prefix-index
branch
from
November 21, 2026 13:38
d1a9ee9 to
0a141f2
Compare
cursor
Bot
force-pushed
the
upstream/dialect-prefix-index
branch
3 times, most recently
from
November 21, 2026 19:08
9fca456 to
02997eb
Compare
KKould
force-pushed
the
upstream/dialect-prefix-index
branch
2 times, most recently
from
November 21, 2026 20:27
eebee1b to
4f34d2b
Compare
KKould
self-requested a review
November 21, 2026 20:46
KKould
force-pushed
the
upstream/dialect-prefix-index
branch
from
November 22, 2026 08:11
061d6e8 to
7de5d36
Compare
KKould
approved these changes
Nov 22, 2026
KKould
left a comment
Member
There was a problem hiding this comment.
This pull request was originally just for parser compatibility. I added KiteSQL's index implementation logic to the pull request to achieve compatibility, and enabled the default dialect option.
This was referenced Nov 22, 2026
Add SqlDialect::supports_index_prefix_length(), defaulting to false. When a dialect returns true, a key part written `col(n)` with a positive integer length `n` (which the parser reads as a call) is accepted as `col` in PRIMARY KEY and UNIQUE constraints and in CREATE INDEX. The length is not stored: the whole value is indexed, and a unique key compares whole values. GenericSqlDialect keeps rejecting such key parts with the same errors as before, and DynDialect forwards the hook to its current dialect. A unit test in src/dialect/mod.rs covers both dialects. Co-authored-by: Alex Skinner <alexskinner@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Part of #403.
Depends on #404 (please review only the last commit; I'll rebase once #404 lands).
What
SqlDialect::supports_index_prefix_length() -> bool, defaulting tofalse.true, a key part writtencol(n)with a positive integernis accepted ascolinPRIMARY KEYandUNIQUEconstraints and inCREATE INDEX. The parser readscol(n)as a function call. The length isn't stored: the whole value is indexed, and a unique key compares whole values.col(0),col(other_col),upper(col), an unknown column) is rejected as before.GenericSqlDialect, such key parts are rejected with the same errors as today.docs/features.md.Why
Schemas written for some dialects routinely use prefix key parts such as
UNIQUE (name(191)). This lets a dialect crate accept them without changing what core stores or how indexes behave. See #403.Testing
src/dialect/mod.rs: the generic dialect still rejects a prefix key part, and a test-only dialect acceptsUNIQUE (b(4))andCREATE INDEX .. (b(2)), rejects a zero length, and enforces uniqueness on the whole value.make test(650 passed, 2 ignored),make test-async(595 passed),make test-sltandmake test-slt-async(198 files each),make fmtand all fourmake clippyinvocations pass.make test-wasmpasses too.Notes for review
falseby default, as it is now.