Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Escape double '??' to a literal '?' #5

Closed
wants to merge 14 commits into from
Closed

Conversation

Vlix
Copy link
Contributor

@Vlix Vlix commented Feb 1, 2019

This was already a pull request in lpsmith's repo, but now moved here.

This change seeks to allow for the usage of the JSON operators new to PostgreSQL since version 9.4 that use a question mark (namely: ?, ?| and ?&) by way of escaping double question marks to a literal question mark in the resulting query.

This shouldn't break any existing code, since any occurrence of double question marks of which none are to be replaced by a value would be an error in any pre-existing code.

Vlix and others added 9 commits March 14, 2018 00:33
This change makes it possible to use literal question marks in queries to PostgreSQL. This is needed to be able to use the new JSON operators. https://www.postgresql.org/docs/9.5/static/functions-json.html

This change can't break anything, since:

* Anyone using double question marks would get an error if not supplied the adequate amount of accompanying values (in case of people trying the new JSON operators); or

* If supplied the adequate amount of accompanying values, PostgreSQL would throw a fit because you'd supply two values directly next to each other, which doesn't make sense.
@Vlix
Copy link
Contributor Author

Vlix commented Feb 1, 2019

I'm suspecting this travis build also uses PostgreSQL 9.3 or less.
I'm not sure how to change which version of PostgreSQL is used by the Travis build. Help would be appreciated.

@phadej
Copy link
Collaborator

phadej commented Feb 1, 2019 via email

@phadej
Copy link
Collaborator

phadej commented Feb 1, 2019 via email

@Vlix
Copy link
Contributor Author

Vlix commented Feb 3, 2019

Ok, everything should be ready to merge. Do I have to add something to the CHANGELOG.md, or does someone else do that?

@Vlix
Copy link
Contributor Author

Vlix commented Feb 3, 2019

Yet, ?? Escaping can be test insite string literal, can't it?

Sent from my iPhone
On 1 Feb 2019, at 23.05, Oleg Grenrus @.> wrote: https://docs.travis-ci.com/user/database-setup/#using-a-different-postgresql-version Sent from my iPhone > On 1 Feb 2019, at 14.49, Felix Paulusma @.> wrote: > > I'm suspecting this travis build also uses PostgreSQL 9.3 or less. > I'm not sure how to change which version of PostgreSQL is used by the Travis build. Help would be appreciated. > > — > You are receiving this because you are subscribed to this thread. > Reply to this email directly, view it on GitHub, or mute the thread.

I've added a test that just uses the function that escapes double question marks and breaks on single ones on a regular (byte)string, for completeness.

The other tests I already put in there make sure the question mark operators behave as expected and that double ?? do indeed turn into something PostgreSQL can use for JSON operations.

@Vlix
Copy link
Contributor Author

Vlix commented Feb 21, 2019

Any idea if/when this will be merged?

@phadej
Copy link
Collaborator

phadej commented Feb 21, 2019 via email

@phadej
Copy link
Collaborator

phadej commented Feb 25, 2019

squashed in #8

@phadej phadej closed this Feb 25, 2019
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.

None yet

2 participants