Ticket #110 (closed defect: wontfix)
Regarding getWhere().addWhere() in recent (r413 or better) Reactor builds
| Reported by: | TomChiverton | Owned by: | dhughes |
|---|---|---|---|
| Type: | defect | Priority: | low |
| Milestone: | 1.0 Release | Component: | Reactor - Object Oriented Queries |
| Version: | Severity: | trivial | |
| Keywords: | Cc: |
Description
In r377 (or there abouts) it was possible to do:
q.getWhere().addWhere(makeAWhere(aGateway))
and have makeWhere() construct a new Where object from aGateway.createQuery()
and all would be fine.
Now, I think because of the parsed query cache, this doesn't work, and you
have to pass the query object into makeAWhere() and generate the where from
there, otherwise the value of the isEqual() or whatever is lost.
I may be wrong, and I may have been abusing it in the past, but, it used to work, and updating to a newer Reactor made it stop, I'm fairly sure.
The Where stores not the value passed to isEqual(), but pushes the value onto an
internal list, and stores 'use value index 1', right ?
When returning from makeAWhere(), this internal list was clobered (I can
understand why).
So if the makeAWhere() returned a where with one clause, and the caller went
on to add another two clauses, then you'd end up with the internal list of
the Where having the first two locations the same (set to the first value
added by the caller).
Before addAWhere():
<cffunction name="addAWhere" access="public" hint="">
<cfargument name="clientIDs" required="true">
<cfargument name="tableName" required="false" default="cases">
<cfargument name="gateway" required="false" default="#variables.Reactor#">
<cfscript>
var gw=arguments.gateway.createGateway(arguments.tableName);
var w2=;
w2=gw.createQuery();
w2.getWhere().setMode('Or');
for (i=1;i lte listLen(arguments.clientIDs);i=i+1){
w2.getWhere().isEqual(arguments.tableName,'clientCode',trim(listGetAt(arguments.clientIDs,i)));
}
return w2.getWhere();
</cfscript>
</cffunction>
After addAWhere():
<cffunction name="addAWhere" access="package" hint="">
<cfargument name="clientIDs" required="true">
<cfargument name="q" required="true" >
<cfargument name="tableName" required="false" default="cases">
<cfscript>
arguments.q.getWhere().setMode('Or');
for (i=1;i lte listLen(arguments.clientIDs);i=i+1){
arguments.q.getWhere().isEqual(arguments.tableName,'clientCode',trim(listGetAt(arguments.clientIDs,i)));
}
return arguments.q;
</cfscript>
</cffunction>

