#1 2020-07-22 08:12:12

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Query with 'FileName LIKE "%.%"' fails

Assume the TSQLRecord-derived class has a property called 'FileName'
This query clause:

FileName LIKE "%.%"

As in

db.Retrieve('FileName LIKE "%.%"', [], [True], theRecord)

Will fail (not raising errors but just don't return the correct result).

As a workaround I use 'InStr(FileName, ".")>0' insead, but it's an issue that needs to be fixed, I guess.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#2 2020-07-22 08:13:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Re: Query with 'FileName LIKE "%.%"' fails

The % character is used as place-holder for variables in FormatUTF8(), as with Retrieve().
So you should set ['%','%'] as parameters, or use a method with no FormatUTF8() call.

Offline

#3 2020-07-22 08:46:38

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Query with 'FileName LIKE "%.%"' fails

Thanks for the comment, ab, I forgot about that :0

But I guess it's better if mORMot support escaping, for example, '\%' won't be treated as a parameter.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

#4 2020-07-22 09:18:06

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,673
Website

Re: Query with 'FileName LIKE "%.%"' fails

It would break existing code, so using '%' as parameter is the way to go.

I have specified it now in the documentation, which was not handling this subject.
See https://synopse.info/fossil/info/bc360e800a

Offline

#5 2020-07-22 10:14:30

edwinsn
Member
Registered: 2010-07-02
Posts: 1,218

Re: Query with 'FileName LIKE "%.%"' fails

Great! I think it's ok.


Delphi XE4 Pro on Windows 7 64bit.
Lazarus trunk built with fpcupdelux on Windows with cross-compile for Linux 64bit.

Offline

Board footer

Powered by FluxBB