Skip to content

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

Closed
Vlix wants to merge 14 commits into
haskellari:masterfrom
Vlix:master
Closed

Vlix wants to merge 14 commits into
haskellari:masterfrom
Vlix:master

Conversation

@Vlix

@Vlix Vlix commented Feb 1, 2019 •

Copy link
Copy Markdown
Contributor

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

Vlix commented Feb 1, 2019

Copy link
Copy Markdown
Contributor Author

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

phadej commented Feb 1, 2019 via email

Copy link
Copy Markdown
Collaborator

@phadej

phadej commented Feb 1, 2019 via email

Copy link
Copy Markdown
Collaborator

@Vlix

Vlix commented Feb 3, 2019

Copy link
Copy Markdown
Contributor Author

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

@Vlix

Vlix commented Feb 3, 2019 •

Copy link
Copy Markdown
Contributor Author

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

Vlix commented Feb 21, 2019

Copy link
Copy Markdown
Contributor Author

Any idea if/when this will be merged?

@phadej

phadej commented Feb 21, 2019 via email

Copy link
Copy Markdown
Collaborator

@phadej

phadej commented Feb 25, 2019

Copy link
Copy Markdown
Collaborator

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.

2 participants