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

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

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

Post by MarkF » Fri 27 Jan 2017 15:21

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.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Mon 30 Jan 2017 09:30

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.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

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

Post by MarkF » Mon 30 Jan 2017 12:28

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?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Tue 31 Jan 2017 08:58

Thank you for the information. We have fixed this behavior.

MarkF
Posts: 211
Joined: Thu 02 Mar 2006 14:55

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

Post by MarkF » Tue 31 Jan 2017 13:00

Excellent. Thanks for the help.

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

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

Post by AlexP » Tue 31 Jan 2017 13:38

You are welcome. Feel free to contact us if you have any further questions.

Post Reply