summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2007-08-05 17:54:10 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2007-08-05 17:54:10 +0000
commitf7537bc7fc40a20fe1a6dc1438edb804ebe099f4 (patch)
tree3be0ca737ddc5619e65ecb8babbf4a0281ba5d63 /doc
parent4b0c565c5ab0a1556e2c8f7caceb2229827c6eea (diff)
downloadsqlalchemy-f7537bc7fc40a20fe1a6dc1438edb804ebe099f4.tar.gz
edits
Diffstat (limited to 'doc')
-rw-r--r--doc/build/content/mappers.txt6
1 files changed, 3 insertions, 3 deletions
diff --git a/doc/build/content/mappers.txt b/doc/build/content/mappers.txt
index 01d274e48..0bf928074 100644
--- a/doc/build/content/mappers.txt
+++ b/doc/build/content/mappers.txt
@@ -835,7 +835,7 @@ Would be represented with data such as:
5 3 subchild2
6 1 child3
-A one-to-many relationship for the above looks exactly like any other one-to-many relationship. When SQLAlchemy encounters the relation from `treenodes` to `treenodes`, it assumes one-to-many unless told otherwise:
+SQLAlchemy's `mapper()` configuration for a self-referential one-to-many relationship exactly like a "normal" other one-to-many relationship. When SQLAlchemy encounters the foreign key relation from `treenodes` to `treenodes`, it assumes one-to-many unless told otherwise:
{python title="Adjacency List One-To-Many"}
# entity class
@@ -860,7 +860,7 @@ And the bi-directional version combines both:
'children':relation(Node, backref=backref('parent', remote_side=[nodes.c.id]))
})
-There are several examples included with SQLAlchemy illustrating self-referential strategies; these include [basic_tree.py](rel:http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/adjacencytree/basic_tree.py) and [optimized_al.py](rel:http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/elementtree/optimized_al.py), the latter of which illustrates how to persist and search XML documents in conjunction with [ElementTree](rel:http://effbot.org/zone/element-index.htm).
+There are several examples included with SQLAlchemy illustrating self-referential strategies; these include [basic_tree.py](http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/adjacencytree/basic_tree.py) and [optimized_al.py](http://www.sqlalchemy.org/trac/browser/sqlalchemy/trunk/examples/elementtree/optimized_al.py), the latter of which illustrates how to persist and search XML documents in conjunction with [ElementTree](http://effbot.org/zone/element-index.htm).
##### Self-Referential Query Strategies {@name=query}
@@ -868,7 +868,7 @@ Querying self-referential structures is done in the same way as any other query
{python}
# get all nodes named 'child2'
- sess.query(Node).filter(data='child2')
+ sess.query(Node).filter(Node.data=='child2')
On the subject of joins, i.e. those described in [datamapping_joins](rel:datamapping_joins), self-referential structures require the usage of aliases so that the same table can be referenced multiple times within the FROM clause of the query. Aliasing can be done either manually using the `nodes` `Table` object as a source of aliases: