fix: parse quoted PostgreSQL string arrays#737
Conversation
Welcome, @immanuwell!Thanks for your first contribution! Before we proceed with the review, please sign the Fiduciary License Agreement: Once signed, this PR will be automatically updated. |
Thanks, @immanuwell! 🎉Your CLA has been signed and is now on file. We'll proceed with the review shortly. |
|
@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, "}") { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Side note: I guess we're lacking tests for such cases.
|
Hey @immanuwell Thanks for the fix 🙌 I just added one question before we approve. |
what
Fix
StringArrayPostgreSQL 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:
The new regression cases show it:
go test ./utils -run TestStringArray_Scanchecks
go test ./utils -run TestStringArraygo test ./cache ./models ./utils ./config/kafkaNo linked issue found. Searched issues and PRs for
StringArray,PostgreSQL array, andevents-processor.