]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
give a meaningful name of association table 5371/head
authoraplatkouski <5857672+aplatkouski@users.noreply.github.com>
Mon, 22 Jun 2020 15:28:23 +0000 (18:28 +0300)
committeraplatkouski <5857672+aplatkouski@users.noreply.github.com>
Mon, 22 Jun 2020 15:28:23 +0000 (18:28 +0300)
Signed-off-by: aplatkouski <5857672+aplatkouski@users.noreply.github.com>
doc/build/orm/extensions/declarative/relationships.rst

index 5d81cee30acd664a0167e6063aacef669a3f2782..09d71c00ccc853fddbe53e3404a7b40a95c0a547 100644 (file)
@@ -152,16 +152,16 @@ with declarative as with traditional mappings. The
 traditional way.  The :class:`_schema.Table` usually shares
 the :class:`_schema.MetaData` object used by the declarative base::
 
-    keywords = Table(
+    keyword_author = Table(
         'keywords', Base.metadata,
         Column('author_id', Integer, ForeignKey('authors.id')),
-        Column('keyword_id', Integer, ForeignKey('keyword.id'))
+        Column('keyword_id', Integer, ForeignKey('keywords.id'))
         )
 
     class Author(Base):
         __tablename__ = 'authors'
         id = Column(Integer, primary_key=True)
-        keywords = relationship("Keyword", secondary=keywords)
+        keywords = relationship("Keyword", secondary=keyword_author)
 
 Like other :func:`~sqlalchemy.orm.relationship` arguments, a string is accepted
 as well, passing the string name of the table as defined in the
@@ -170,7 +170,7 @@ as well, passing the string name of the table as defined in the
     class Author(Base):
         __tablename__ = 'authors'
         id = Column(Integer, primary_key=True)
-        keywords = relationship("Keyword", secondary="keywords")
+        keywords = relationship("Keyword", secondary="keyword_author")
 
 As with traditional mapping, its generally not a good idea to use
 a :class:`_schema.Table` as the "secondary" argument which is also mapped to