Skip to content

WIP: SQL INSERT table placeholders (#146) - #169

Draft
apstndb wants to merge 1 commit into
mainfrom
scaffold/issue-146-table-placeholder
Draft

apstndb wants to merge 1 commit into
mainfrom
scaffold/issue-146-table-placeholder

Conversation

@apstndb

@apstndb apstndb commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Summary

Draft scaffold for #146 — not merge-ready.

  • Adds WithSQLTablePlaceholder(token) on SQLInsertWriter.
  • Placeholder tokens are emitted verbatim (no dialect identifier quoting); column names remain dialect-quoted.
  • Allows NewSQLInsertWriter(out, "") when a placeholder is configured.
  • ErrEmptyTablePlaceholder rejects empty placeholder tokens at construction.

Passing scaffold tests

  • TABLE_NAME placeholder with GoogleSQL column quoting
  • /* unresolved table */ placeholder with PostgreSQL "id" column quoting

Skipped golden sketches

Dependency on #147

#147 proposes rejecting NewSQLInsertWriter(out, "") at construction when no placeholder is set. This scaffold intentionally allows empty table only when WithSQLTablePlaceholder is present — the two issues must land together with clear error semantics:

Case Expected behavior (TBD)
table="", no placeholder ErrEmptyTableName at construction (#147)
table="", with placeholder OK
table="users", with placeholder Undecided — skipped test

Open design questions

Test plan

Closes #146 when complete — this PR is design review only.

Made with Cursor

Add WithSQLTablePlaceholder for verbatim INSERT targets when the table name
is unresolved; golden tests sketch PG column quoting with raw placeholders.

Co-authored-by: Cursor <cursoragent@cursor.com>

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request introduces support for SQL table placeholders in SQLInsertWriter via the new WithSQLTablePlaceholder option, allowing verbatim INSERT INTO target tokens when the real table name is unknown at export time. It also includes corresponding unit tests and error handling for empty placeholders. A review comment suggests updating the TableName() method to return the configured placeholder when set, ensuring consistency with its documented contract.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread writer/writer.go
sqlDialect databasepb.DatabaseDialect
batchSize int
batchPending int
tablePlaceholder string

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

When tablePlaceholder is configured, the actual table name used in the generated INSERT statements will be the placeholder, not table. However, TableName() currently still returns w.table (which may be empty). To ensure consistency with its documented contract ('TableName returns the qualified table name used in INSERT statements'), TableName() should be updated to return w.tablePlaceholder if it is set.

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.

writer: reject empty SQLInsertWriter table name at construction writer: consider explicit SQL INSERT table placeholders for generic exports

1 participant