summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/ext/sqlsoup.py
diff options
context:
space:
mode:
authorJonathan Ellis <jbellis@gmail.com>2007-01-23 06:28:24 +0000
committerJonathan Ellis <jbellis@gmail.com>2007-01-23 06:28:24 +0000
commitf68e1f45022b04aeaa0f88dee4085412a3cd8d2d (patch)
tree71ef864d8d84562d30219f64739105d62c81429f /lib/sqlalchemy/ext/sqlsoup.py
parent39028216619204d1ddbe35ef1d767e43c2f5b4c3 (diff)
downloadsqlalchemy-f68e1f45022b04aeaa0f88dee4085412a3cd8d2d.tar.gz
add example of joining to labeled table
Diffstat (limited to 'lib/sqlalchemy/ext/sqlsoup.py')
-rw-r--r--lib/sqlalchemy/ext/sqlsoup.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/sqlalchemy/ext/sqlsoup.py b/lib/sqlalchemy/ext/sqlsoup.py
index f9c13d388..390a2c16d 100644
--- a/lib/sqlalchemy/ext/sqlsoup.py
+++ b/lib/sqlalchemy/ext/sqlsoup.py
@@ -159,6 +159,12 @@ to disambiguate columns with their table name:
>>> db.with_labels(join1).c.keys()
['users_name', 'users_email', 'users_password', 'users_classname', 'users_admin', 'loans_book_id', 'loans_user_name', 'loans_loan_date']
+You can disambiguate just one table in a join by applying labels to that table,
+and joining on the returned object:
+ >>> labeled_loans = db.with_labels(db.loans)
+ >>> db.join(db.users, labeled_loans, isouter=True).c.keys()
+ ['name', 'email', 'password', 'classname', 'admin', 'loans_book_id', 'loans_user_name', 'loans_loan_date']
+
Advanced Use
============
@@ -196,7 +202,10 @@ just needs to be unique within the select, and not necessarily correspond to a
>>> years_with_count.select_by(published_year='1989')
[MappedBooks(published_year='1989',n=1)]
-Obviously if we just wanted to get a list of counts associated with book years once, raw SQL is going to be less work. The advantage of mapping a Select is reusability, both standalone and in Joins. (And if you go to full SQLAlchemy, you can perform mappings like this directly to your object models.)
+Obviously if we just wanted to get a list of counts associated with book years
+once, raw SQL is going to be less work. The advantage of mapping a Select is
+reusability, both standalone and in Joins. (And if you go to full SQLAlchemy,
+you can perform mappings like this directly to your object models.)
Raw SQL