Page 1 of 1

Can't filter on a field name that contains a single quote.

Posted: Fri 27 Jan 2017 15:21
by MarkF
It appears that the Filter property of ODAC datasets can't handle field names with single quotes. A simple example would be:

select 'Testing' from dual; (Field name will be 'Testing' with the single quotes.)
But setting the Filter properly to "TESTING' = 'Testing'" does not appear to work (internally the single quotes are stripped.)

Another example might be:
select 'Testing' "Mark's Field" from dual;
Setting the Filter properly to Mark's Field = 'Testing' will cause an error.

From looking at the code it looks like we can add square brackets around the name field, but unfortunately the single quotes still cause problems.

Thanks for any tips or thoughts.

Re: Can't filter on a field name that contains a single quote.

Posted: Mon 30 Jan 2017 09:30
by AlexP
Hello,

If there are single or double quotes in the filter, we consider it as the string beginning, but not the field name, as strings must be quoted. Therefore, in the filter expression for such fields, you should use square brackets.

Re: Can't filter on a field name that contains a single quote.

Posted: Mon 30 Jan 2017 12:28
by MarkF
I'm happy to use square brackets, but what if the field name contains a single quote? It appears that they are not preserved and therefore the internal FindField call fails. Is there a way to escape a single quote between square brackets such that it is preserved?

Re: Can't filter on a field name that contains a single quote.

Posted: Tue 31 Jan 2017 08:58
by AlexP
Thank you for the information. We have fixed this behavior.

Re: Can't filter on a field name that contains a single quote.

Posted: Tue 31 Jan 2017 13:00
by MarkF
Excellent. Thanks for the help.

Re: Can't filter on a field name that contains a single quote.

Posted: Tue 31 Jan 2017 13:38
by AlexP
You are welcome. Feel free to contact us if you have any further questions.