summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/declarative.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2011-12-29 11:27:50 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2011-12-29 11:27:50 -0500
commitae53c42d3c6748a15cbd0b5b1b5d90d59bf9d3ca (patch)
tree7b2911ece931a19030e28e0e17657233e24b9f0d /lib/sqlalchemy/ext/declarative.py
parent7f07d43fb127a2b2283a7d17a714ed175498b6b9 (diff)
downloadsqlalchemy-ae53c42d3c6748a15cbd0b5b1b5d90d59bf9d3ca.tar.gz
document that strings are accepted with declarative/secondary
Diffstat (limited to 'lib/sqlalchemy/ext/declarative.py')
-rwxr-xr-xlib/sqlalchemy/ext/declarative.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/sqlalchemy/ext/declarative.py b/lib/sqlalchemy/ext/declarative.py
index dc84c5dfb..46d267faa 100755
--- a/lib/sqlalchemy/ext/declarative.py
+++ b/lib/sqlalchemy/ext/declarative.py
@@ -185,6 +185,15 @@ the :class:`.MetaData` object used by the declarative base::
id = Column(Integer, primary_key=True)
keywords = relationship("Keyword", secondary=keywords)
+Like other :func:`.relationship` arguments, a string is accepted as well,
+passing the string name of the table as defined in the ``Base.metadata.tables``
+collection::
+
+ class Author(Base):
+ __tablename__ = 'authors'
+ id = Column(Integer, primary_key=True)
+ keywords = relationship("Keyword", secondary="keywords")
+
As with traditional mapping, its generally not a good idea to use
a :class:`.Table` as the "secondary" argument which is also mapped to
a class, unless the :class:`.relationship` is declared with ``viewonly=True``.