From 7e7d233cf3a0c66980c27db0fcdb3c7d93bc2510 Mon Sep 17 00:00:00 2001 From: aplatkouski <5857672+aplatkouski@users.noreply.github.com> Date: Mon, 22 Jun 2020 18:28:23 +0300 Subject: [PATCH] give a meaningful name of association table Signed-off-by: aplatkouski <5857672+aplatkouski@users.noreply.github.com> --- doc/build/orm/extensions/declarative/relationships.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/doc/build/orm/extensions/declarative/relationships.rst b/doc/build/orm/extensions/declarative/relationships.rst index 5d81cee30a..09d71c00cc 100644 --- a/doc/build/orm/extensions/declarative/relationships.rst +++ b/doc/build/orm/extensions/declarative/relationships.rst @@ -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 -- 2.47.3