[
https://issues.apache.org/jira/browse/CMIS-498?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Florian Müller reassigned CMIS-498:
-----------------------------------
Assignee: Florian Müller
> Aphostrophes in hard coded string literals are removed in
> org.apache.chemistry.opencmis.client.runtime.QueryStatementImpl
> -------------------------------------------------------------------------------------------------------------------------
>
> Key: CMIS-498
> URL: https://issues.apache.org/jira/browse/CMIS-498
> Project: Chemistry
> Issue Type: Bug
> Components: opencmis-client
> Affects Versions: OpenCMIS 0.6.0
> Environment: Ubuntu 11.04 64bit OpenJDK Runtime Environment (IcedTea6
> 1.10.4) (6b22-1.10.4-0ubuntu1~11.04.2)
> Reporter: Bojan Nemec
> Assignee: Florian Müller
> Labels: newbie
>
> Aphostrophes in hard coded string literals are removed.
> A simple query without parameters will not work:
> {code}
> QueryStatement st = session.createQueryStatement("select * from cmis:document
> where cmis:createdBy = \'admin\'");
> System.out.println(st.toQueryString());
> {code}
> prints out
> {code}select * from cmis:document where cmis:createdBy = admin{code}
> instead of
> {code}select * from cmis:document where cmis:createdBy = 'admin'{code}
> obvious is that this query will not work when sent to a cmis server.
> For my opinion the code of the *toQueryString* method should be something
> like this:
> {code}
> public static String toQueryString() {
> boolean inStr = false;
> int parameterIndex = 0;
> StringBuilder sb = new StringBuilder();
> for (int i = 0; i < statement.length(); i++) {
> char c = statement.charAt(i);
> if (c == '\'') {
> if (inStr && statement.charAt(i - 1) == '\\') {
> inStr = true;
> } else {
> inStr = !inStr;
> }
> sb.append(c); // without this line all ' are
> removed!
> } else if (c == '?' && !inStr) { // added && !inStr to have ? in
> string literals
> parameterIndex++;
> String s = parametersMap.get(parameterIndex);
> if (s == null) {
> sb.append(c);
> } else {
> sb.append(s);
> }
> } else {
> sb.append(c);
> }
> }
> return sb.toString();
> }
> {code}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira