Page 1 of 1

Locate problem

Posted: 03.09.2008, 21:11
by Christian
I have big trouble with zeos Locate.
Locate dont match records with both an clear Field. For my opinion this is wrong

Example:

I Search for

ID;VERSION;LANGUAGE
01,NULL, EN


In my Dataset exists an exact Match for this

01,NULL, EN

Zeos says thers no match couse VERSION is NULL....

In ZDataSetutils in CompareFieldsFromResultSet

is one Line at Line 10801 : Result := Result and not ResultSet.WasNull;
Thats the problem. Ive commented it out and everything is fine.
Why is this so ?
Is it needed ?

best Regards
Christian

Posted: 18.11.2008, 16:20
by Cocky
I would be also interested in an answer. :D

best regards

Cocky

Posted: 18.11.2008, 20:45
by mdaems
Can you make a test project (a very simple one) including a table creation script and file it in the bug tracker? (http://zeosbugs.firmos.at/)
Like a TZConnection, a TZQuery and a button which opens the query and then does the locate returning the wrong result? That's something I can debug. Don't forget to mention compiler and database you are using.

Mark

Posted: 19.11.2008, 09:48
by seawolf
Try this test (package ZTestComponentAll, unit ZTestDatasetGeneric)

procedure TZGenericTestDbcResultSet.TestQueryLocate;
var
Query: TZQuery;
ResData : boolean;
begin
Query := TZQuery.Create(nil);
try
Query.Connection := Connection;
Query.SQL.Add('select * from cargo');
Query.ExecSQL;
Query.Open;
Check(Query.RecordCount > 0, 'Query return no records');
ResData := Query.Locate('C_DEP_ID;C_WIDTH;C_SEAL',VarArrayOf(['1','10','2']),[loCaseInsensitive]);
CheckEquals(ResData,true);
ResData := Query.Locate('C_DEP_ID,C_WIDTH,C_SEAL',VarArrayOf(['2',varNull,'1']),[loCaseInsensitive]);
CheckEquals(ResData,true);
finally
Query.Free;
end;
end;

First and second check are ok, but 3rd always return false

The problem is located on that line

Query.Locate('C_DEP_ID,C_WIDTH,C_SEAL',VarArrayOf(['2',varNull,'1']),[loCaseInsensitive]);
CheckEquals(ResData,true);

Could be?

Query.Locate('C_DEP_ID,C_WIDTH,C_SEAL',VarArrayOf(['2',varEmpty,'1']),[loCaseInsensitive]);
CheckEquals(ResData,true);

Could be?

Query.Locate('C_DEP_ID,C_WIDTH,C_SEAL',VarArrayOf(['2','','1']),[loCaseInsensitive]);
CheckEquals(ResData,true);

Could be?

Query.Locate('C_DEP_ID,C_WIDTH,C_SEAL',VarArrayOf(['2','NULL','1']),[loCaseInsensitive]);
CheckEquals(ResData,true);

Posted: 20.11.2008, 00:04
by mdaems
seawolf,
I'm afraid your test is wrong.

Code: Select all

VarArrayOf(['2',varNull,'1'])
is equal to

Code: Select all

VarArrayOf(['2',1,'1'])
Of course, this doesn't return a result.
Use

Code: Select all

VarArrayOf(['2',Null,'1'])
Now the tests do work correctly. I'll add them to the test suite next time I commit.
A remark : you should use

Code: Select all

CheckEquals(true,ResData);
instead of

Code: Select all

CheckEquals(ResData,true);
The expected value comes first.

Cocky,
Christian,
Waiting for an exact sample of your problem.

Mark

Posted: 29.11.2008, 09:29
by Christian
With actual SVN it seems to work now. Have removed my patch from my local code repositore and first try seems to work.