Skip to content

fix(pg): run a named statement with an empty text more than once - #3781

Open
nigrosimone wants to merge 3 commits into
brianc:masterfrom
nigrosimone:fix-named-empty-statement
Open

nigrosimone wants to merge 3 commits into
brianc:masterfrom
nigrosimone:fix-named-empty-statement

Conversation

@nigrosimone

@nigrosimone nigrosimone commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

client.query({ text: '', name: 'empty' }) works once and fails from the second run on with prepared statement "empty" already exists. On ParseComplete the client records the name with its text, '', and hasBeenParsed then tests that text for truth, so the statement is read as never parsed and is sent to Parse again. The native client keeps its own map of names and reads it the same way.

The fix checks both caches by presence rather than by the truth of the text.

The added test runs a named empty statement twice: it fails on master, on both clients, and passes here.

@brianc brianc 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 - i never would have thought to even test for this. Looks solid to me. I have a nit though: it looks ilke maybe the comments are claude generated? The way it "talks" is overly clever. I prefer writing comments in a more straight-forward voice. Maybe "check for undefined, not falsy. support empty query text." or no comment at all?

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