]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fix Association Proxy example
authorGord Thompson <gord@gordthompson.com>
Tue, 11 Apr 2023 19:56:37 +0000 (13:56 -0600)
committerGord Thompson <gord@gordthompson.com>
Tue, 11 Apr 2023 19:56:37 +0000 (13:56 -0600)
Minor corrections to "Simplifying Association
Objects" example in the Association Proxy docs.

https: //github.com/sqlalchemy/sqlalchemy/discussions/9636
Change-Id: Ib433cf78b149d330889d947bbaf2b03c9dd87c29

doc/build/orm/extensions/associationproxy.rst

index fda09327215eb3f1fdf6bd52f7ccca7862310cb7..e612ce1bb6c5288e43fe4ee126a93829f2b531f4 100644 (file)
@@ -181,6 +181,7 @@ collection of ``User`` to the ``.keyword`` attribute present on each
 
     from __future__ import annotations
 
+    from typing import List
     from typing import Optional
 
     from sqlalchemy import ForeignKey
@@ -213,7 +214,9 @@ collection of ``User`` to the ``.keyword`` attribute present on each
         keywords: AssociationProxy[List[Keyword]] = association_proxy(
             "user_keyword_associations",
             "keyword",
-            creator=lambda keyword: UserKeywordAssociation(keyword=Keyword(keyword)),
+            creator=lambda keyword_obj: UserKeywordAssociation(
+                keyword=keyword_obj
+            ),
         )
 
         def __init__(self, name: str):