-
-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SQL to Caml parser is not happy about escaped quotes #89
Comments
Can you show me the full query that you try to parse ? |
I'll assume it's : In that case you can proceed this way: $SP().list("The List").get({
whereCAML:true,
where:$SP().parse("Parent = 'Support and deliver roll out of "Sale Management"' AND ID <> 400", false)
}) So you replace the quotes by |
I cannot do that. These are dynamic generated queries so I do not know which other chars that needs to be escaped. The weird thing is that it is only an issue when the escaped ' or " are followed by a non-escaped ' or " respectively. When it is the last item in this loop: SharepointPlus/sharepointplus-5.0.js Lines 818 to 823 in e64bb70
If you notice in my samples it inserts a null instead of the escaped " or ' |
What is your code exactly? Because if I do this: var parent = 'Support and deliver roll out of "Sale Management"';
var id = 400;
var where = $SP().parse("Parent = '"+parent+"' AND ID <> "+id);
console.log(where); // -> <And><Eq><FieldRef Name="Parent" /><Value Type="Text">Support and deliver roll out of "Sale Management"</Value></Eq><Neq><FieldRef Name="ID" /><Value Type="Number">400</Value></Neq></And>
$SP().list("The List").get({
where:where
})
.then(function(data) {
console.log(data.length); // -> return X
}) Then it does work... |
So, is it OK now? |
Hi @Aymkdn As I have tried to explain above, this is a narrow case, but not okay. The workaround you describe is also the one I have temporarily implemented already, however what I tried to describe is a bug in the code.
and
will always fail, because of the escaped " or ' inside the " or ' in the query. Because the Does that make sense? The output in my original post (after I have cleaned up a little) directly from my code. The |
The output from the parse function will for both the
Notice the Null and that the next part is joined into the Value tag |
Actually the issue is due to
The |
If you want to test, replace ligne 694 by : var queryString = q.replace(/(\s+)?(=|~=|<=|>=|<>|<|>| LIKE | IN )(\s+)?/g,"$2").replace(/([^\\?])""|([^\\?])''/g,"$1Null").replace(/==/g,"="); // remove unnecessary white space & replace ' And let me know please ! |
Did you get a chance to test it @petero-dk ? |
Not yet, been away since. On my todo when I get back
|
OK. Please let me know when you get back :-) |
Sorry to hurry you, but it's been a while now and I'd like to close this issue. If you don't reply soon, then I'll assume it works OK with this fix and it will be released for v5.1. Thanks. |
Ill check today |
No news, so I'm closing it. Feel free to comment back if you want to. Thanks for reporting back this issue! |
When parsed becomes
It seems to affect the second escaped "
If I switch around and use single ' they do have the same problem if the ' is the last item in the quotations.
Actually the problem is having the same escaped character as the quotation character in a where clause
The text was updated successfully, but these errors were encountered: