Hello!
I noticed that using asterisk as filter works fine only when I use * at the end of fileterd string ie. 'Test*'
When I use asterisk at the beginning ie. '*test' or use two asteriscs in the filter reults are not intuitive.
I tested on firebird db and sqlite db. Lets create any db and a table TABLE with one column COLUMN and fill it with values (1,2,1150,4311). Lets connect to db using a query 'select COLUMN from TABLE'. I tested using Zeoslib 7.1.2 TZConnection and TZQuery. Let's put TDataSource and TDBGrid components on a form and fill the Filter property using: grid.DataSource.Dataset.Filter = '11*'. The result will be correct: 1150. But when you put two wildcards '*11*' or put wildcard on the beginning of the string the result will be wrong: (1,2,1150,1143) instead of (1150, 1143).
I worked with Lazarus 0.9.3, 1.0, 1.1.99-pre, 1.2RC1 and 1.3.
With Zeos lib 6x, 7x
With SQL lite, MSSQL and Firebird
And in all cases I had the same problem with using wildcards, so I thought that problem must be somewhere in TDataSet component.
I published the problem on Lazasus forum but they anounced that this must be a problem with ZeosLib.
Regards,
Krzysztof
TZQuery Filter with * problem
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
Re: TZQuery Filter with * problem
Hi,
I remember I recently wrote a quick (and therefore not complete) answer for this problem.
Have a look here : http://zeoslib.sourceforge.net/viewtopi ... 38&t=11288
I know, I ask some effort and hope you can fix it for us, but with our limited 'staff' this will take ages otherwise.
Mark
I remember I recently wrote a quick (and therefore not complete) answer for this problem.
Have a look here : http://zeoslib.sourceforge.net/viewtopi ... 38&t=11288
I know, I ask some effort and hope you can fix it for us, but with our limited 'staff' this will take ages otherwise.
Mark
Re: TZQuery Filter with * problem
krzynio8,
According to me it should be:And it works for me on Zeos7.2-alpha branches_ testing_r3109.
Michal
Strange that it works at all.grid.DataSource.Dataset.Filter = '11*' (or '*11*')
According to me it should be:
Code: Select all
DBGrid1.DataSource.DataSet.Filter := 'FName1 like ''*11*'''
Michal
Re: TZQuery Filter with * problem
Thank you very much for all.
The key was the module ZMatchPattern.
I just wanted to find a pattern in any place of a field value.
So, simple modification of IsMatch procedure solved my problem.
Thanks again and regards, Krzysztof
The key was the module ZMatchPattern.
I just wanted to find a pattern in any place of a field value.
So, simple modification of IsMatch procedure solved my problem.
Code: Select all
function IsMatch(const Pattern, Text: string): Boolean;
begin
if Pos(AnsiLowerCase(Pattern), AnsiLowerCase(Text))>0 then
Result := True
else
Result := False;
// Result := (Matche(Pattern, Text) = 1);
end;