]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix the runtime issue related to the join operation in the association example (...
authorBOBOTANG <tzfjobmail@gmail.com>
Wed, 4 Sep 2024 18:26:52 +0000 (02:26 +0800)
committerGitHub <noreply@github.com>
Wed, 4 Sep 2024 18:26:52 +0000 (20:26 +0200)
examples/association/basic_association.py
examples/association/proxied_association.py

index d2271ad430e30fe4e58dbee1697c4182b9d88382..7a5b46097e3c4006e2b15de48c7c4e63a5bc3efa 100644 (file)
@@ -105,7 +105,7 @@ if __name__ == "__main__":
     )
 
     # print customers who bought 'MySQL Crowbar' on sale
-    q = session.query(Order).join("order_items", "item")
+    q = session.query(Order).join(OrderItem).join(Item)
     q = q.filter(
         and_(Item.description == "MySQL Crowbar", Item.price > OrderItem.price)
     )
index 0ec8fa899ac990257288ca508cc463b7c45cb45e..65dcd6c0b66e9cddb5e9442eaea20e6903fc558a 100644 (file)
@@ -112,7 +112,8 @@ if __name__ == "__main__":
     # print customers who bought 'MySQL Crowbar' on sale
     orders = (
         session.query(Order)
-        .join("order_items", "item")
+        .join(OrderItem)
+        .join(Item)
         .filter(Item.description == "MySQL Crowbar")
         .filter(Item.price > OrderItem.price)
     )