add ?-contained operator support#227
add ?-contained operator support#227davecramer merged 4 commits intopgjdbc:masterfrom tminglei:contains-operator
Conversation
|
Sorry to be a nag, but this should be documented in |
|
Hi @ringerc I just added the doc for ?-contained operator support. But, can you help double check it, since I'm not very familiar with the syntax. Thanks for your nice help! :) |
|
Is this pull request acceptable? |
|
Sorry I will open up some time to get to this shortly. 9.4 has been released today and I will attempt to get most if not all Dave Cramer On 18 December 2014 at 09:34, 涂名雷 notifications@github.com wrote:
|
|
Well, so it missed the latest release? But any way thank you for your nice help! =) |
|
No it has not missed the latest release. What I meant to say is I will find Dave Cramer On 18 December 2014 at 09:54, 涂名雷 notifications@github.com wrote:
|
|
Glad to hear that! Thank you very much!! =) |
|
Hi, It would appear something in this pull broke the build. Can you look Dave Cramer On 18 December 2014 at 10:02, 涂名雷 notifications@github.com wrote:
|
|
I don't know why, but it seems not related to my changes. |
|
I just initiated a build with your code and that is what is failing. Why do Dave Cramer On 19 December 2014 at 06:25, 涂名雷 notifications@github.com wrote:
|
|
As you know, my first commit built passed, and second commit built failed. |
|
I'm not sure I understand what 'impossible to break the build means' . Currently it is not. I will have a quick look to see what the issue is. Dave Cramer On 19 December 2014 at 06:34, 涂名雷 notifications@github.com wrote:
|
|
Well, my second commit is just some word changes in |
|
OK, I have verified that Parser.unmarkDoubleQuestion is removing the second Dave Cramer On 19 December 2014 at 06:55, 涂名雷 notifications@github.com wrote:
|
|
This code ); seems to be the culprit, what I don't understand is how this passed before Dave Cramer On 19 December 2014 at 08:07, Dave Cramer davecramer@gmail.com wrote:
|
|
But this code was copied from pgjdbc itself. So strange?! |
|
Stranger that it passed the first time and doesn't now Dave Cramer On 19 December 2014 at 08:56, 涂名雷 notifications@github.com wrote:
|
|
so, do you have any idea? |
|
well I can fix the code by changing i-j to i-j+1 I am running the tests Where did you copy this from in the code ? Dave Cramer On 19 December 2014 at 09:18, 涂名雷 notifications@github.com wrote:
|
|
Well, I think it was from So it's obvious that I introduced the defect. Sorry! |
|
Well I see the difference and why it is now failing. What I don't the V2Query code just jumps over the single, double quotes and then your code copies it in but fails to copy the last single or double quote. Does your code currently pass tests on your machine ? This is what I changed your code to: switch (aChars[i]) standardConformingStrings); Dave Cramer On 19 December 2014 at 09:39, 涂名雷 notifications@github.com wrote:
|
|
Unfortunately this fails for me on the comments, and I have no more time I really want to see this get in the code, but at this point it's not ready Dave Cramer On 19 December 2014 at 10:00, Dave Cramer davecramer@gmail.com wrote:
|
|
Ok, I'll check it agian. Sorry for the inconvenience to you! |
There was a problem hiding this comment.
Note: the offset will be set a value outside of array length when it's the last line
|
Hi @davecramer resolved, pls help check again. For the cause, I think it's related to that I have different local environment, and maybe I also made some other mistakes. |
add ?-contained operator support Thanks for all your work on this!
|
I'm curious about how this relates to the potential of there being a |
Does that answer your question? |
|
Hmm, I think I have already seen such an operator somewhere (like The trouble I'm having with this escaping technique is the fact that JDBC code will no longer be executable in PostgreSQL directly. Besides, JDBC code now depends on whether a prepared statement or a static statement is used: // Works today, with single question mark
c.createStatement().executeQuery("select '{}'::jsonb ?| array['a', 'b']");
// Will now require a double question mark for escaping
c.prepareStatement("select '{}'::jsonb ??| array['a', 'b']").executeQuery();I just don't have a good feeling with this escaping of the question mark. Perhaps, I would have wished for the PostgreSQL JDBC driver to implement some smart parser logic to see if at any given location, a bind variable is even allowed. For instance, when writing The reason why I'm concerned is because this affects all upstream APIs (like jOOQ, JDBI, MyBatis, JPA, etc.). Specifically, if an upstream API allows for reading SQL strings from external sources (e.g. from templates), then the author of the external source will need to know that the statement will be processed with JDBC eventually... |
|
Hi Lukas, Obviously this is not a great situation. However there really isn't a great Dave Cramer On 14 July 2016 at 08:45, Lukas Eder notifications@github.com wrote:
|
|
I don't have a suggestion, but a workaround: http://stackoverflow.com/a/38370973/521799 Just use the corresponding |
|
On Thu, Jul 14, 2016 at 8:54 AM, Lukas Eder notifications@github.com
That works but is limited. Some parts of PostgreSQL require the use of an David J. |
I'm afraid, full or close to full parsing is required to tell if When translating to SQL it might be |
Resending for #187. Pls help review and merge. Thanks!
Currently it seems PgJDBC didn't support ?-contained operator escaping, which lead to some ?-contained operators, such as hstore's
?&/?|and ltree's?/?~/?@and so on, can't be used in PreparedStatement.This pull request try to resolve the problem.
How to use it?
double mark the
?when passing a raw sql to connection's prepareStatement method, as below:Then PgJDBC won't treat the
??as parameter placeholders, and will restore it back to?before sending to postgres server.