Skip to content

fix(numbering): quote the counter column in the increment SET expression (PostgreSQL)#6392

Merged
delchev merged 1 commit into
masterfrom
fix/numbering-postgres-quoted-counter
Jul 22, 2026
Merged

fix(numbering): quote the counter column in the increment SET expression (PostgreSQL)#6392
delchev merged 1 commit into
masterfrom
fix/numbering-postgres-quoted-counter

Conversation

@delchev

@delchev delchev commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Problem

The master build's integration-tests-postgresql job fails in NumberingSdkIT.allocatesAGapFreeFormattedSequence (h2 job is green):

org.postgresql.util.PSQLException: ERROR: column "document_counter" does not exist
  Position: 62
  at ...DocumentNumberStore.increment(DocumentNumberStore.java:158)

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 left unquoted. PostgreSQL lower-cases unquoted identifiers, so it looked for document_counter and 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 NumberingSdkIT against a real postgres:16 using the CI datasource env (DIRIGIBLE_DATASOURCE_DEFAULT_*):

  • before the fix: column "document_counter" does not exist;
  • after the fix: Tests run: 1, Failures: 0, Errors: 0 — BUILD SUCCESS.

NumberingSdkIT runs in both the h2 and postgresql CI jobs, so it guards this regression going forward.

🤖 Generated with Claude Code

…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>
@delchev
delchev merged commit 2728f89 into master Jul 22, 2026
10 checks passed
@delchev
delchev deleted the fix/numbering-postgres-quoted-counter branch July 22, 2026 21:02
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.

1 participant