Repository navigation
Conversation
|
@kshvakov is attempting to deploy a commit to the coolajitpratapsingh0-9932's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
INSERT INTO core."user" AS u (...) is standard PostgreSQL that GoSQLX rejected with E2002 (expected VALUES, SELECT, or WITH, got AS). Real libpg_query parses the AS form and rejects the bare-alias form, so AS after the target table is unambiguous and is accepted regardless of dialect, mirroring how OUTPUT is accepted dialect-agnostically. - ast: InsertDialectFields gains TableAlias / TableAliasQuote next to TableNameQuote (Extras keeps the pinned InsertStatement size) - parser: after the target table name, consume AS + identifier with the same reserved-word guard the UPDATE/DELETE target alias uses - ast SQL(): writeInsertHead renders ' AS alias' with quoting - tests: parse shape, quoted target, no-column-list and INSERT...SELECT forms through the grammar-gap harness (parse + SQL + re-parse fixpoint); error pins for non-identifier, missing and reserved-word aliases and for the bare alias without AS
Codecov flagged the three sql_dml.go patch lines as uncovered: Go coverage profiles are per-package, so the parser tests that exercise writeInsertHead do not count toward the ast package's profile. Adds two cases to TestInsertStatementSQL_Forms — a plain alias and a quoted alias — both rendered through InsertStatement.SQL().
kshvakov
force-pushed
the
feat/insert-target-alias
branch
from
November 15, 2026 21:48
feb0682 to
3d3fe30
Compare
This branch has not been deployed
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.
INSERT INTO core."user" AS u (org_id, ...) VALUES (...) RETURNING u.idis standard PostgreSQL that GoSQLX currently rejects with
E2002: expected VALUES, SELECT, or WITH, got AS.Verified against libpg_query (
pg_query.Parse): theASform parses(
INSERT INTO t AS u (a) VALUES (1)→ ok), the bare-alias form does not(
INSERT INTO t u→ invalid SQL). Accepting only theASform thereforekeeps the grammar unambiguous across all dialects — mirroring how the SQL
Server OUTPUT clause is already accepted dialect-agnostically.
Changes:
ast:InsertDialectFieldsgainsTableAlias/TableAliasQuotenextto
TableNameQuote(stored in Extras, keeping the pinnedInsertStatementstruct size unchanged)parser: after the target table name, consumeAS+ identifier withthe same reserved-word guard the UPDATE/DELETE target alias uses
astSQL():writeInsertHeadrendersAS aliaswith quotingTests (
pkg/sql/parser/insert_grammar_gaps_test.go):core."user"), no-column-list andINSERT ... SELECTforms through the grammar-gap harness(parse +
SQL()+ re-parse fixpoint)alias, bare alias without AS
Real-world case that surfaced this: production Go code formatting SQL
literals with
INSERT INTO core."user" AS u (...) ... RETURNING u.id, u.org_id, .... Changelog fragment:changelog.d/insert-target-alias.added.md.go test ./...passes; the only failure,scripts/perf/gateTestProfileCachegrindTable, fails identically on cleanmain(environment-dependent perf gate, unrelated).