Closed sqlalchemy-bot closed 16 years ago
Anonymous wrote:
Simple patch that cures filter-o2o.py in both ==None and !=None cases (but probably breaks something else)
Anonymous wrote:
This patch has broken ==None comparison for the one-to-many relations though the secondary table.
filter(Folder.parent == None) now results in
SELECT folder.id AS folder_id, folder.name AS folder_name
FROM folder, folder_hier
WHERE folder.id = folder_hier.child AND folder_hier.parent IS NULL ORDER BY folder.oid
instead of (before the patch applied)
SELECT folder.id AS folder_id, folder.name AS folder_name
FROM folder
WHERE NOT (EXISTS (SELECT 1
FROM folder_hier
WHERE folder.id = folder_hier.child)) ORDER BY folder.oid
Michael Bayer (zzzeek) wrote:
very nice. You're on the right track but I corrected the patch to check specifically for the "ONETOMANY" "direction", since thats actually whats at play here, and added unit tests for all o2m/m2o/o2o combinations of ==None/!=None in 3175686514dc75acfa3ed0be92f31535325c60dd. thanks for the patch / test !
Anonymous wrote:
a testcase
Anonymous wrote:
Example test case for wrong generation of relation query on backref o2o
Changes by Anonymous: set attachment to "simple-patch.txt"
Changes by Michael Bayer (zzzeek): set state to "resolved"
Changes by Anonymous: removed "resolved" state
Changes by Michael Bayer (zzzeek): set state to "resolved"
Changes by Anonymous: set attachment to "test.py"
Changes by Anonymous: set attachment to "filter-o2o.py"
Issue created by Anonymous
While comparison to None in one-to-many relations works, for one-to-one it generates completely wrong query, as illustrated in filter-o2o.py
Also, != comparison to None in uselist=False case generates somewhat non leading exception, in contrast to case uselist=True.
But, it seems to me that it isn't much work to extend the ne to work as negated eq in comparison to None (in case of uselist=False, at least).
I've attached a simple patch which cures above mentioned - but it should be taken only as example of what I'm talking about, because I haven't dig into the rest of comparators and don't really understand the code.
Attachments: simple-patch.txt | filter-o2o.py | test.py