Skip to content

Fix ON CONFLICT placeholder numbering when inserting multiple rows - #6

Merged
jgaskins merged 1 commit into
jgaskins:masterfrom
concentric-health:fix-multi-row-upsert
Aug 17, 2026
Merged

Fix ON CONFLICT placeholder numbering when inserting multiple rows#6
jgaskins merged 1 commit into
jgaskins:masterfrom
concentric-health:fix-multi-row-upsert

Conversation

@mloughran

@mloughran mloughran commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

CreateManyOperation numbered the placeholders after ON CONFLICT incorrectly.

For example, the added spec generated:

INSERT INTO users ("email", "name") VALUES ($1, $2), ($3, $4) ON CONFLICT (email) DO UPDATE SET name = $3

which is incorrect and fails with "bind message supplies 5 parameters, but prepared statement requires 4".

Fixed version:

INSERT INTO users ("email", "name") VALUES ($1, $2), ($3, $4) ON CONFLICT (email) DO UPDATE SET name = $5

CreateManyOperation numbered the placeholders after ON CONFLICT incorrectly.

For example, the added spec generated:

    INSERT INTO users ("email", "name") VALUES ($1, $2), ($3, $4) ON CONFLICT (email) DO UPDATE SET name = $3

which is incorrect and fails with "bind message supplies 5 parameters, but prepared statement requires 4".

Fixed version:

    INSERT INTO users ("email", "name") VALUES ($1, $2), ($3, $4) ON CONFLICT (email) DO UPDATE SET name = $5

@jgaskins jgaskins left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice, thank you!

@jgaskins
jgaskins merged commit c3b5116 into jgaskins:master Aug 17, 2026
30 checks passed
@mloughran
mloughran deleted the fix-multi-row-upsert branch August 24, 2026 22:41
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