Repository navigation
fix(postgrest): quote column names in the insert and upsert columns parameter - #1448
Open
AndroidPoet wants to merge 1 commit into
Open
AndroidPoet wants to merge 1 commit into
AndroidPoet wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
What
insertandupsertwith aJsonArraybody send the keys of the rows as thecolumnsquery parameter, joined without quotes. PostgREST only accepts unquoted names made of letters, digits,_,$and spaces, and it trims surrounding spaces (pIdentifierinsrc/library/PostgREST/ApiRequest/QueryParams.hs). A table with a column likeprice (usd)ora.bgets a PGRST100 parse error on insert and upsert, and a column with leading or trailing spaces is matched against the trimmed name.supabase-js, supabase-swift and supabase-flutter quote every name here, so the same table works from those clients.
Fix
Wrap each column name in double quotes in both places that build
columns. Quoted names are matched exactly, so plain names likedataresolve to the same column as before.Tests
testInsertValuesandtestUpsertValuesnow expect"data".testInsertQuotesColumnNamesandtestUpsertQuotesColumnNamessendprice (usd)anda.b.The 4 tests fail without the fix. All 198 Postgrest JVM tests pass with it, and detekt is clean.
No public API change.