Subject | RE: BUG IN LOCATE(): Fwd: [IBO] IB_Query.Locate problem |
---|---|
Author | Jason Wharton |
Post date | 2004-10-27T20:09:34Z |
I believe I have resolved this issue!
In IB_Components.pas around line 27200:
if not RefiningSQL {Add begin} and not ( Self is TIB_LocateCursor ) {Add
end} then
begin
for ii := MasterLinks.Count - 1 downto 0 do
begin
if Assigned( FBindingCursor ) then
BindingParam := '=?' + IB_BindLink + IntToStr( ii )
else
BindingParam := '=?' + GetMasterLinkParamName( ii );
AddWhereClauseHigh( NewWhereClause,
MasterLinks.IndexNames[ ii ] + BindingParam );
end;
end;
The internal locate cursor was incorrectly picking up the master detail
linkage and doubling it up unnecessarily. By doing this it allows the
locate cursor to simply use what it gets from the main query.
Jason Wharton
In IB_Components.pas around line 27200:
if not RefiningSQL {Add begin} and not ( Self is TIB_LocateCursor ) {Add
end} then
begin
for ii := MasterLinks.Count - 1 downto 0 do
begin
if Assigned( FBindingCursor ) then
BindingParam := '=?' + IB_BindLink + IntToStr( ii )
else
BindingParam := '=?' + GetMasterLinkParamName( ii );
AddWhereClauseHigh( NewWhereClause,
MasterLinks.IndexNames[ ii ] + BindingParam );
end;
end;
The internal locate cursor was incorrectly picking up the master detail
linkage and doubling it up unnecessarily. By doing this it allows the
locate cursor to simply use what it gets from the main query.
Jason Wharton
> -----Original Message-----y.Locate.
> From: Helen Borrie [mailto:helebor@...]
> Sent: Sunday, July 18, 2004 8:04 AM
> To: Jason Wharton
> Subject: BUG IN LOCATE(): Fwd: [IBO] IB_Query.Locate problem
>
>
> Jason,
>
> I've played with Mihai's test case and it sure looks like a
> bug to me.
> Download link is at the bottom.
>
> He does (unnecessarily) have a VarArray for the second argument, but
> changing it to a variant doesn't change the wrong SQL that
> IBO generates
> for the locate...
>
> regards.
> Helen
>
> >To: IBObjects@yahoogroups.com
> >User-Agent: eGroups-EW/0.82
> >From: "Mihai Chezan" <gsmcq@...>
> >Date: Sun, 18 Jul 2004 13:19:43 -0000
> >Subject: [IBO] IB_Query.Locate problem
> >
> >I have 2 tables:
> >CREATE TABLE dep (
> > id_dep INTEGER NOT NULL,
> > name VARCHAR(50) NOT NULL,
> > CONSTRAINT dep_pk PRIMARY KEY (id_dep)
> >);
> >
> >CREATE TABLE person (
> > id_person INTEGER NOT NULL,
> > name VARCHAR(50) NOT NULL,
> > id_dep INTEGER NOT NULL,
> > CONSTRAINT person_pk PRIMARY KEY (id_person)
> >);
> >
> >I have an IB_QueryDep as master and an IB_QueryPerson as detail.
> >If I make an
> >IB_QueryPerson.Locate('name', VarArrayOf(['michael']), []))
> >the locate fails even if michael exists.
> >The locate fails because the generated sql for locate looks
> like this:
> >SELECT person.id_person
> >FROM
> > person
> >WHERE person.id_dep=? /* BIND_0 */
> > AND person.id_dep=? /* MLNK_ID_DEP_0 */
> > AND (((PERSON.NAME = ? /* LOC_1_PERSON_NAME */ )))
> >
> >and as parameters values:
> > [BIND_0] = <n> 0
> > [MLNK_ID_DEP_0] = 2
> > [LOC_1_PERSON_NAME] = 'michael' ]
> >
> >But the sql should have been:
> >SELECT person.id_person
> >FROM
> > person
> >WHERE
> > person.id_dep=? /* MLNK_ID_DEP_0 */
> > AND (((PERSON.NAME = ? /* LOC_1_PERSON_NAME */ )))
> >
> >or the parameter values should have been:
> > [BIND_0] = 2
> > [MLNK_ID_DEP_0] = 2
> > [LOC_1_PERSON_NAME] = 'michael' ]
> >
> >If I remove the master detail relation then it works ok:
> >SELECT person.id_person
> >FROM
> > person
> >WHERE (((PERSON.NAME = ? /* LOC_1_PERSON_NAME */ )))
> >
> >Where is the problem?
> >
> >I've included a test-case Problem-IB_Query.Locate.zip:
> >http://groups.yahoo.com/group/IBObjects/files/Problem-IB_Quer
>zip