]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- also add the alternate approach, name column distinctly from attribute name,
authorMike Bayer <mike_mp@zzzcomputing.com>
Wed, 16 Jul 2014 19:24:32 +0000 (15:24 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Wed, 16 Jul 2014 19:25:06 +0000 (15:25 -0400)
ref #3129

lib/sqlalchemy/ext/automap.py

index a4f86c78a14d9964f01e64433130e093a0231410..121285ab3a8809d805cac807e709c7f3f934fff5 100644 (file)
@@ -432,6 +432,20 @@ We can resolve this conflict by using an underscore as follows::
     Base.prepare(engine, reflect=True,
         name_for_scalar_relationship=name_for_scalar_relationship)
 
+Alternatively, we can change the name on the column side.   The columns
+that are mapped can be modified using the technique described at
+:ref:`mapper_column_distinct_names`, by assigning the column explicitly
+to a new name::
+
+    Base = automap_base()
+
+    class TableB(Base):
+        __tablename__ = 'table_b'
+        _table_a = Column('table_a', ForeignKey('table_a.id'))
+
+    Base.prepare(engine, reflect=True)
+
+
 Using Automap with Explicit Declarations
 ========================================