fix(numbering): quote the counter column in the increment SET expression (PostgreSQL)#6392
Merged
Merged
Conversation
…ion (PostgreSQL) DocumentNumberStore creates DIRIGIBLE_DOCUMENT_NUMBERS with quoted (case-sensitive, upper-case) identifiers, and the SQL builder encapsulates the SET-target column and the WHERE-condition identifiers the same way. But the increment's SET VALUE is a free expression appended verbatim - `SET "DOCUMENT_COUNTER" = DOCUMENT_COUNTER + 1` - whose column reference was NOT quoted. On a case-folding dialect (PostgreSQL lower-cases unquoted identifiers) it resolved to `document_counter`, which does not match the quoted-upper-case column: `ERROR: column "document_counter" does not exist`. H2 upper-cases unquoted identifiers, so it happened to match there - which is why the h2 integration job was green while integration-tests-postgresql failed in NumberingSdkIT.allocatesAGapFreeFormattedSequence. Fix: quote the column reference in the SET value expression (QUOTED_COUNTER). The WHERE columns stay unquoted on purpose - the builder encapsulates those, and quoting them here double-encapsulates into a zero-length delimited identifier. Verified: NumberingSdkIT run against a real postgres:16 (the CI datasource env) is green after the fix (was: column-does-not-exist). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.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.
Problem
The
masterbuild's integration-tests-postgresql job fails inNumberingSdkIT.allocatesAGapFreeFormattedSequence(h2 job is green):DocumentNumberStorecreatesDIRIGIBLE_DOCUMENT_NUMBERSwith quoted (case-sensitive, upper-case) identifiers, and the SQL builder encapsulates the SET-target column and the WHERE-condition identifiers the same way. But the increment's SET value is a free expression appended verbatim —SET "DOCUMENT_COUNTER" = DOCUMENT_COUNTER + 1— whose column reference was left unquoted. PostgreSQL lower-cases unquoted identifiers, so it looked fordocument_counterand could not find the quoted-upper-case column. H2 upper-cases unquoted identifiers, so it happened to match there — hence the green/red split.Fix
Quote the column reference in the SET value expression (
QUOTED_COUNTER). One line.The WHERE columns stay unquoted on purpose: the builder encapsulates those for us — quoting them explicitly double-encapsulates into a
zero-length delimited identifier ""error (confirmed empirically while iterating).Verification
Ran
NumberingSdkITagainst a realpostgres:16using the CI datasource env (DIRIGIBLE_DATASOURCE_DEFAULT_*):column "document_counter" does not exist;Tests run: 1, Failures: 0, Errors: 0— BUILD SUCCESS.NumberingSdkITruns in both the h2 and postgresql CI jobs, so it guards this regression going forward.🤖 Generated with Claude Code