Skip to content
This repository was archived by the owner on Oct 9, 2025. It is now read-only.

Conversation

inian
Copy link
Member

@inian inian commented Mar 11, 2021

fixes #164

This only quotes values and not column names. Previous bugs were due to quoting column names.

I also add in a check to only quote the value if the filter value contains a postgrest special character.

@inian inian requested a review from soedirgo March 11, 2021 09:37
Copy link
Member

@soedirgo soedirgo left a comment

Choose a reason for hiding this comment

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

LGTM 👍 though I'd wait for steve's response on properly quoting " itself

@inian inian requested a review from steve-chavez March 11, 2021 10:15
@steve-chavez
Copy link
Member

Something I've noticed is that the cleanFilterArray function is also applied to the cs, cd and ov operators and those don't need special handling. Their filter value is just a string, cleanFilterArray could be removed from them.

test('cs', async () => {
const res = await postgrest.from('users').select().cs('age_range', '[1,2)')
expect(res).toMatchSnapshot()
})

test('cd', async () => {
const res = await postgrest.from('users').select().cd('age_range', '[1,2)')
expect(res).toMatchSnapshot()
})

test('ov', async () => {
const res = await postgrest.from('users').select().ov('age_range', '[2,25)')
expect(res).toMatchSnapshot()
})

@soedirgo
Copy link
Member

Gotcha, thanks Steve!

Co-authored-by: Steve Chavez <stevechavezast@gmail.com>
@soedirgo
Copy link
Member

Should be good now @inian, feel free to merge 👍

@soedirgo soedirgo force-pushed the fix/special-characters-filter-values branch from 1866016 to 5c36f1d Compare March 11, 2021 15:07
@inian inian merged commit 8ba6cb8 into master Mar 11, 2021
@inian
Copy link
Member Author

inian commented Mar 11, 2021

Thanks Bobbie and Steve!

@inian inian deleted the fix/special-characters-filter-values branch March 11, 2021 15:44
@github-actions
Copy link

🎉 This PR is included in version 0.26.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Handle Postgrest special characters

3 participants