Community
Participate
Working Groups
Build Identifier: Consider the statement : select '?', :myText from dual Expected SQL with binds: SELECT '?', :myText FROM DUAL IN :myText => ? [CHAR lorem] Expected SQL PLAIN Log: SELECT '?', 'lorem' FROM DUAL But is: SQL PLAIN Log: SELECT '' LOREM *** UNPARSED *** '' , ? FROM DUAL because the first '?' is interpreted as a placeholder for the parameter :myText. Responsible is calculation of pos: at org.eclipse.scout.rt.server.services.common.jdbc.internal.exec.StatementProcessor.createSqlDump(StatementProcessor.java:690) Solution: use a RegEx that do not find ? between single quotes. Reproducible: Always
Created attachment 211226 [details] test for bug 371963 Unit Test to illustrate the problem. testSelectPlainText() contains the case described in the bug description. To be run with as normal JUnit Test. Dependency on EasyMock.
Created attachment 211227 [details] Patch for bug 371963 Patch proposition. There is maybe a better possible implementation for the find() function. RegEx optimization and so on... Here a test for this function: @Test public void testFind() throws Exception { runFind(-1, null, 0); runFind(0, "?", 0); runFind(3, "xx ?", 0); runFind(3, "xx ? xxx", 0); runFind(-1, "?", 1); runFind(3, "xx ?", 1); runFind(3, "xx ? xxx", 1); runFind(-1, "xx ?", 4); runFind(-1, "xx ? xxx", 4); runFind(0, "??", 0); runFind(3, "xx ??", 0); runFind(3, "xx ??", 3); runFind(4, "xx ??", 4); runFind(3, "xx ? ?", 3); runFind(5, "xx ? ?", 4); runFind(7, "xx ? xx?x", 4); runFind(-1, "'?'", 0); runFind(4, "'?' ? x", 0); runFind(7, "xx '?' ? x", 0); runFind(3, "xx ? xx '?' '?' ? x", 0); runFind(16, "xx ? xx '?' '?' ? x", 4); runFind(-1, "xx ? xx '?' '?' ? x", 17); runFind(-1, "xx '?' xx", 0); runFind(-1, "xx '????' xx", 0); runFind(12, "xx '????' x ? x", 0); runFind(8, "xx '' x ? x", 0); runFind(-1, "xx '' xx", 0); runFind(-1, "xx ' '' ? '' ' xx", 0); runFind(-1, "xx ''' ? ' ' ' xx", 0); runFind(6, "xx '' ? '' xx", 0); runFind(6, " '''' ? '' xx", 0); } private void runFind(int expected, String s, int start) { Assert.assertEquals(expected, StatementProcessor.find(s, start)); } An other possibility is to extend this StatementProcessor.find(..) function to be more generic: StringUtility.findExcludingTocken(String s, String what, String excludedTocken, int start) Should be consistent with: StringUtility.find(..) Please add the JUnit test case at the appropriate place.
Applied patch with small modifications, marked contributed by J.B.
Many thanks to Jeremie, good work.
ticket closed. deliverd as part of eclipse scout 3.8.0 (juno release train)