Skip to content

parser/test + docs: close out the column-loop interactions audit#99

Merged
winebarrel merged 2 commits into
mainfrom
test-parse-inline-column-loop
May 6, 2026
Merged

parser/test + docs: close out the column-loop interactions audit#99
winebarrel merged 2 commits into
mainfrom
test-parse-inline-column-loop

Conversation

@winebarrel

Copy link
Copy Markdown
Owner

Summary

Last open audit item from the PR #84 postmortem ("parseCreateTable column-loop interactions"). Two sub-bullets remained; verified each against the current code:

Sub-bullet 1: `inline UNIQUE × DEFAULT 'x'` — testable, pinned

vitess parses the shape cleanly. `parseColumnDef` wires the DEFAULT onto the column; `applyInlineColumnKey` promotes UNIQUE to a column-named index. Both attributes survive in the model independently. Added `TestParseInlineColumnUniqueWithDefault` to pin the regression net.

Sub-bullet 2: `inline PRIMARY KEY × CHECK (col > 0)` — unreachable, dropped

The TODO framing said "vitess promotes column-level CHECK to a table-level constraint." Probing showed the premise is wrong: vitess does not parse column-level CHECK at all. Every variant fails with `syntax error near 'CHECK'`:

```
id INT CHECK (...) → syntax error
id INT NOT NULL CHECK (...) → syntax error
id INT PRIMARY KEY CHECK (...) → syntax error
```

MySQL itself accepts these shapes and stores the constraint under `

chk`, but vitess hasn't implemented the column-level grammar. There is no reachable code path to test.

Changes

  • `parser/parser_test.go`: `TestParseInlineColumnUniqueWithDefault` — pins UNIQUE × DEFAULT.
  • `TODO.md`: drop the "Medium — test coverage gaps" section. Sub-bullet 1 is tested; sub-bullet 2 was based on a false premise.
  • `CAVEATS.md`: new "Inline column-level CHECK is rejected by the parser" section. Documents the MySQL-accepts-but-vitess-rejects asymmetry, points users at the table-level form, and notes that `dump` already emits the table-level shape so import flows are unaffected.

Test plan

  • `make lint` clean.
  • `make test` all 6 packages green.
  • `TestParseInlineColumnUniqueWithDefault` passes.

🤖 Generated with Claude Code

Last open audit item from PR #84 postmortem. Two sub-bullets,
both verified against the current code:

- inline `UNIQUE × DEFAULT 'x'`: vitess parses it cleanly,
  parseColumnDef wires DEFAULT onto the column, and
  applyInlineColumnKey promotes UNIQUE to a column-named index.
  Both attributes survive in the model independently. Pin with
  `TestParseInlineColumnUniqueWithDefault`.

- inline `PRIMARY KEY × CHECK (col > 0)`: the TODO entry
  framed this as "vitess promotes column-level CHECK to a
  table-level constraint — the promotion path interacts with
  the PK promotion path." The premise was wrong: vitess does
  not parse column-level CHECK at all (every variant —
  `id INT CHECK (...)`, `id INT NOT NULL CHECK (...)`,
  `id INT PRIMARY KEY CHECK (...)` — fails with `syntax error
  near 'CHECK'`). MySQL itself accepts the shape and stores the
  constraint under an auto-name; vitess simply hasn't
  implemented the column-level grammar. There is no reachable
  interaction to test.

Drop the TODO entry now that one sub-bullet is pinned and the
other is unreachable. CAVEATS.md gets a new "Inline
column-level CHECK is rejected by the parser" section so users
who hit the vitess error have a clear diagnosis and the
table-level workaround.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 6, 2026 05:39
@codecov

codecov Bot commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.96%. Comparing base (6bd127c) to head (472ad07).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #99   +/-   ##
=======================================
  Coverage   86.96%   86.96%           
=======================================
  Files          30       30           
  Lines        3321     3321           
=======================================
  Hits         2888     2888           
  Misses        266      266           
  Partials      167      167           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Closes the last open audit items from the PR #84 postmortem around parseCreateTable “column-loop interactions”, by pinning the reachable UNIQUE×DEFAULT interaction in a unit test and documenting that inline column-level CHECK is not supported by the Vitess parser (despite MySQL accepting it).

Changes:

  • Add a parser unit test that asserts inline UNIQUE promotion and DEFAULT parsing both survive on the same column.
  • Remove the now-resolved/invalidated “Medium — test coverage gaps” TODO section.
  • Document the MySQL-vs-Vitess asymmetry for inline column-level CHECK, with a table-level workaround.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
parser/parser_test.go Adds TestParseInlineColumnUniqueWithDefault to lock in UNIQUE×DEFAULT composed behavior.
TODO.md Removes the completed/invalidated audit item section.
CAVEATS.md Adds guidance that inline column-level CHECK is rejected by Vitess and recommends table-level CHECK.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread CAVEATS.md Outdated
The new "Inline column-level CHECK is rejected by the parser"
section claimed users see the vitess error "verbatim", but
ParseSQL wraps the underlying error with "failed to parse SQL:
%w" before surfacing it. Update the wording to spell out the
wrapping so a user grepping the actual error message finds the
right entry.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@winebarrel winebarrel merged commit 6dddceb into main May 6, 2026
9 checks passed
@winebarrel winebarrel deleted the test-parse-inline-column-loop branch May 6, 2026 05:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants