- attached Criteria.dpr
- attached TestCriteria.pas
- attached Criteria.dproj
Nested Junctions do not create proper Parens in Where clause
Issue #136
resolved
When I run the attached unit test where two disjunctions are being added to a conjunction, I expect to see parens around the results of each disjunction before the conjunction ands them together
See Expected1 and Expected2 constant in the unit test example.
But what I actually get is no parens at all. When I run this junction formula against an actual critteria object I get only parens around the entire where clause.
I have temporarily modified the TJunction.ToSqlString command to add parens at the beginning and end of the method, This is working for me although I get more parens than I want, but the SQL returns the right records.
function TJunction.ToSqlString(const params: IList<TDBParam>;
const command: TWhereCommand; const generator: ISQLGenerator;
addToCommand: Boolean): string;
var
i: Integer;
criterion: ICriterion;
whereField: TSQLWhereField;
begin
Result := '('; <--Added paren here
for i := 0 to fCriterions.Count - 1 do
begin
if i <> 0 then
Result := Result + ' ' + WhereOperatorNames[WhereOperator] + ' ';
criterion := fCriterions[i];
Result := Result + criterion.ToSqlString(params, command, generator, False);
end;
Result := Result + ')'; <--Added paren here
if addToCommand then
begin
whereField := TSQLWhereField.Create(Result, '');
whereField.WhereOperator := woJunction;
command.WhereFields.Add(whereField);
end;
end;
Comments (2)
-
reporter -
repo owner - changed status to resolved
fixed issue
#136→ <<cset 68c3662afe34>>
- Log in to comment