Skip to content

fix: parse quoted PostgreSQL string arrays#737

Open
immanuwell wants to merge 1 commit into
getlago:mainfrom
immanuwell:fix/postgres-string-array-parsing
Open

fix: parse quoted PostgreSQL string arrays#737
immanuwell wants to merge 1 commit into
getlago:mainfrom
immanuwell:fix/postgres-string-array-parsing

Conversation

@immanuwell
Copy link
Copy Markdown

what

Fix StringArray PostgreSQL array fallback parsing.

Quoted commas now stay inside the value. Quoted empty strings are kept too. Small edge case, but yeah, the old split-on-comma path was kinda rough.

repro

Before this patch, these valid PostgreSQL array values parsed wrong:

`{"value,1","value2"}` // became ["value", "1", "value2"]
`{"","value2"}`       // became ["value2"]

The new regression cases show it:

go test ./utils -run TestStringArray_Scan

checks

  • go test ./utils -run TestStringArray
  • go test ./cache ./models ./utils ./config/kafka

No linked issue found. Searched issues and PRs for StringArray, PostgreSQL array, and events-processor.

@cla-check-bot
Copy link
Copy Markdown

cla-check-bot Bot commented May 8, 2026

Welcome, @immanuwell!

Thanks for your first contribution!

Before we proceed with the review, please sign the Fiduciary License Agreement:

Sign the FLA

Once signed, this PR will be automatically updated.

@cla-check-bot
Copy link
Copy Markdown

cla-check-bot Bot commented May 8, 2026

Thanks, @immanuwell! 🎉

Your CLA has been signed and is now on file. We'll proceed with the review shortly.

@groyoh
Copy link
Copy Markdown
Contributor

groyoh commented May 15, 2026

@immanuwell thanks for your contribution. We'll have a look at it.

// Remove curly braces
s = strings.TrimPrefix(s, "{")
s = strings.TrimSuffix(s, "}")
if !strings.HasPrefix(s, "{") || !strings.HasSuffix(s, "}") {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For inputs without braces this changes behavior compared to the old code.

Old code would return two elements for hello,world but new logic would return one element.

Can you please explain if this was made on purpose?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Side note: I guess we're lacking tests for such cases.

@lovrocolic
Copy link
Copy Markdown
Contributor

Hey @immanuwell Thanks for the fix 🙌
State machine looks correct and tests cover the bug 👌

I just added one question before we approve.

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.

3 participants