summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2010-09-05 17:52:33 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2010-09-05 17:52:33 -0400
commit3a12b3540eaaf91e83ebe08ad0df3a0f99ff9876 (patch)
treea362349947193afc380bcdadc1da302cbbd3ac84
parent95e9998c4115b85cfba6f8743e6343ebb6b37fa2 (diff)
downloadsqlalchemy-3a12b3540eaaf91e83ebe08ad0df3a0f99ff9876.tar.gz
fixes
-rw-r--r--doc/build/orm/collections.rst17
-rw-r--r--doc/build/orm/inheritance.rst8
-rw-r--r--lib/sqlalchemy/orm/collections.py2
3 files changed, 15 insertions, 12 deletions
diff --git a/doc/build/orm/collections.rst b/doc/build/orm/collections.rst
index a9a160d9d..73ba1277b 100644
--- a/doc/build/orm/collections.rst
+++ b/doc/build/orm/collections.rst
@@ -51,17 +51,20 @@ applied as well as limits and offsets, either explicitly or via array slices:
posts = jack.posts[5:20]
The dynamic relationship supports limited write operations, via the
-``append()`` and ``remove()`` methods. Since the read side of the dynamic
-relationship always queries the database, changes to the underlying collection
-will not be visible until the data has been flushed:
-
-.. sourcecode:: python+sql
+``append()`` and ``remove()`` methods::
oldpost = jack.posts.filter(Post.headline=='old post').one()
jack.posts.remove(oldpost)
jack.posts.append(Post('new post'))
+Since the read side of the dynamic relationship always queries the
+database, changes to the underlying collection will not be visible
+until the data has been flushed. However, as long as "autoflush" is
+enabled on the :class:`.Session` in use, this will occur
+automatically each time the collection is about to emit a
+query.
+
To place a dynamic relationship on a backref, use ``lazy='dynamic'``:
.. sourcecode:: python+sql
@@ -135,7 +138,7 @@ values accessible through an attribute on the parent instance. By default,
this collection is a ``list``::
mapper(Parent, properties={
- children = relationship(Child)
+ 'children' : relationship(Child)
})
parent = Parent()
@@ -151,7 +154,7 @@ default list, by specifying the ``collection_class`` option on
# use a set
mapper(Parent, properties={
- children = relationship(Child, collection_class=set)
+ 'children' : relationship(Child, collection_class=set)
})
parent = Parent()
diff --git a/doc/build/orm/inheritance.rst b/doc/build/orm/inheritance.rst
index 71b3fb820..65bcd06f9 100644
--- a/doc/build/orm/inheritance.rst
+++ b/doc/build/orm/inheritance.rst
@@ -237,7 +237,7 @@ Using :func:`~sqlalchemy.orm.query.Query.with_polymorphic` with
``with_polymorphic`` setting.
Advanced Control of Which Tables are Queried
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++++++++++++++++++++++++++++++++++++++++++++++
The :meth:`.Query.with_polymorphic` method and configuration works fine for
simplistic scenarios. However, it currently does not work with any
@@ -249,8 +249,8 @@ use the :class:`.Table` objects directly and construct joins manually. For exam
query the name of employees with particular criterion::
session.query(Employee.name).\
- outerjoin((engineer, engineer.c.employee_id==Employee.c.employee_id)).\
- outerjoin((manager, manager.c.employee_id==Employee.c.employee_id)).\
+ outerjoin((engineer, engineer.c.employee_id==Employee.employee_id)).\
+ outerjoin((manager, manager.c.employee_id==Employee.employee_id)).\
filter(or_(Engineer.engineer_info=='w', Manager.manager_data=='q'))
The base table, in this case the "employees" table, isn't always necessary. A
@@ -265,7 +265,7 @@ what's specified in the :meth:`.Session.query`, :meth:`.Query.filter`, or
session.query(engineer.c.id).filter(engineer.c.engineer_info==manager.c.manager_data)
Creating Joins to Specific Subtypes
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
++++++++++++++++++++++++++++++++++++
The :func:`~sqlalchemy.orm.interfaces.PropComparator.of_type` method is a
helper which allows the construction of joins along
diff --git a/lib/sqlalchemy/orm/collections.py b/lib/sqlalchemy/orm/collections.py
index a9ad34239..884ec1122 100644
--- a/lib/sqlalchemy/orm/collections.py
+++ b/lib/sqlalchemy/orm/collections.py
@@ -189,7 +189,7 @@ class collection(object):
The recipe decorators all require parens, even those that take no
arguments::
- @collection.adds('entity'):
+ @collection.adds('entity')
def insert(self, position, entity): ...
@collection.removes_return()