]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
indicate classically mapped relationship in the dataclass example
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 Dec 2020 18:01:52 +0000 (13:01 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 3 Dec 2020 18:01:52 +0000 (13:01 -0500)
Change-Id: Id1e3fb660c2aff107aa4a180ba565ee88fa6f56e
References: #5027

doc/build/orm/mapping_styles.rst

index b8893409420d5ba697078450d226399930d47d9a..8f281b811492356d144050ae3998c7e7a0929d63 100644 (file)
@@ -237,6 +237,7 @@ An example of a mapping using ``@dataclass`` is as follows::
     from sqlalchemy import String
     from sqlalchemy import Table
     from sqlalchemy.orm import registry
+    from sqlalchemy.orm import relationship
 
     mapper_registry = registry()
 
@@ -258,6 +259,11 @@ An example of a mapping using ``@dataclass`` is as follows::
         nickname: str = None
         addresses: List[Address] = field(default_factory=list)
 
+        __mapper_args__ = {
+            "properties" : {
+                "addresses": relationship("Address")
+            }
+        }
 
     @mapper_registry.mapped
     @dataclass