gof wrote:
Otis wrote:
gof wrote:
in the select list there are attributes from table A and B.
the predicate and sort expression are using attributes from table C.
B is parent of A and A is parent of C.
Is there a way to force DISTINCT?
No, as that will create an exception in firebird. (in every other database as well). If it doesn't in firebird, please let me know, but afaik, it does.
so why is not DISTINCT generated in my example?
Because you sort on a field that's not in the select list (i.e. the fields between SELECT and FROM, the real columns returned). I have to test if firebird throws an error as well, but every database I know throws an error when that happens IF distinct is specified.
so if you do:
SELECT DISTINCT A., B.
FROM A join B on..
join C on A... = C...
WHERE somefilter
ORDER BY C.foo
this will give an error normally. I've to test if firebird does this too, but if I'm not mistaken it does throw an exception in this situation.
Otis wrote:
ToQueryText(ref int uniqueMarker) is called.
ok
didn't post the corect method
public override string ToQueryText(ref int uniqueMarker) is not called. I set the breakpoint and nothing...
Hmm, I think I know what's wrong.
I had to add another ToQueryText() overload to make sure expressions were properly handled in HAVING clauses. So there is another overload in Predicate, which is:
public virtual string ToQueryText(ref int uniqueMarker, bool inHavingClause)
You should give your routine that signature and add another one:
public override string ToQueryText(ref int uniqueMarker)
{
return ToQueryText(ref uniqueMarker, false);
}
IPredicate.ToQueryText(ref int) is called from the Select query engine, IPredicate.ToQueryText(ref int, bool) is called from the IPredicateExpression.ToQueryText(ref int, bool).
Sorry to confuse you with that, I should have caught that earlier in the conversation.