Permalink
Browse files

Prettify code and add another regression test

Make the code adhere to project style guidlines.
The new tests verifies that double question marks will work with
simple statements.
  • Loading branch information...
Laurenz Albe
Laurenz Albe committed Nov 20, 2015
1 parent 39d510c commit 2f8a67f7b9ee00cd57fd1d89612995dd339f4192
Showing with 10 additions and 3 deletions.
  1. +5 −3 org/postgresql/core/Parser.java
  2. +5 −0 org/postgresql/test/jdbc3/CompositeQueryParseTest.java
@@ -90,16 +90,18 @@
i++; // make sure the coming ? is not treated as a bind
} else
{
if (withParameters)
if (!withParameters)
{
nativeSql.append('?');
}
else
{
if (bindPositions == null)
bindPositions = new ArrayList<Integer>();
bindPositions.add(nativeSql.length());
int bindIndex = bindPositions.size();
nativeSql.append(NativeQuery.bindName(bindIndex));
}
else
nativeSql.append('?');
}
fragmentStart = i + 1;
break;
@@ -38,6 +38,11 @@ public void testUnquotedQuestionmark()
assertEquals("select '{\"key\": \"val\"}'::jsonb ? 'key'", reparse("select '{\"key\": \"val\"}'::jsonb ? 'key'", true, false, true));
}

public void testRepeatedQuestionmark()
{
assertEquals("select '{\"key\": \"val\"}'::jsonb ? 'key'", reparse("select '{\"key\": \"val\"}'::jsonb ?? 'key'", true, false, true));
}

public void testQuotedQuestionmark()
{
assertEquals("select '?'", reparse("select '?'", true, false, true));

0 comments on commit 2f8a67f

Please sign in to comment.