Hello.
I have just noticed (by accident) a semantic difference of the not-equal
operator (!=), depending on the style used. For example a query
session.query(Foo).filter(Foo.bar_id != bar.id)
produces SQL like (expected)
SELECT *
FROM foo
WHERE foo.bar_id != %(bar_id_1)s
At a guess, I would say that the Python code Foo.bar != bar means that you
are looking for Foo objects that aren't related to bar. This includes Foos that
are related to a *different* Bar instance, as well as Foos that aren't related
to *any* bar instance. In sql terms, foo.bar_id != bar.id OR
I agree with what Simon said, and want to point out that he is assuming
that that Foo.bar is a relationship of Foo to Bar based on Foo.bar_id =
Bar.id
But you should understand that these are two completely different queries
AND you haven't described your model at all.
Kind user inklesspen explained to me on IRC that the problem here is my use
of 'dict()' as a default. I didn't realize that this would result in the
same object being returned each time. Apparently using 'dict' works
instead. Problem solved!
--
You received this message because you are