summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2006-09-28 04:53:00 +0000
committerMike Bayer <mike_mp@zzzcomputing.com>2006-09-28 04:53:00 +0000
commit2fad6acf54241df43030d387c7c9ac3f54df3af5 (patch)
tree6e71ac9fb1f439bb5dcdc52785a6df6f4b3d02df
parent93caa5da2e2174e5a5f059269fcd9eae66f69306 (diff)
downloadsqlalchemy-2fad6acf54241df43030d387c7c9ac3f54df3af5.tar.gz
- added test suite to test improved from_obj/join behavior with Query/eagerloading/SelectResults
- EagerLoader looks more carefully for the correct Table/Join/FromClause to bind its outer join onto - sqlite boolean datatype converts bind params from python booleans to integer - took out assertion raise from 'name' property of CompoundSelect
-rw-r--r--CHANGES3
-rw-r--r--lib/sqlalchemy/databases/sqlite.py2
-rw-r--r--lib/sqlalchemy/orm/properties.py9
-rw-r--r--lib/sqlalchemy/sql.py7
4 files changed, 14 insertions, 7 deletions
diff --git a/CHANGES b/CHANGES
index 8ed6d9772..8e1617c4e 100644
--- a/CHANGES
+++ b/CHANGES
@@ -80,9 +80,12 @@ replace the main table of the query, if the table is somewhere within
the given from_obj. this makes it possible to produce custom joins and
outerjoins in queries without the main table getting added twice.
[ticket:315]
+- eagerloading is adjusted to look in more complicated from clauses
+when attaching to the query.
- added join_to and outerjoin_to transformative methods to SelectResults,
to build up join/outerjoin conditions based on property names. also
added select_from to explicitly set from_obj parameter.
+- sqlite boolean datatype converts False/True to 0/1 by default
0.2.8
- cleanup on connection methods + documentation. custom DBAPI
diff --git a/lib/sqlalchemy/databases/sqlite.py b/lib/sqlalchemy/databases/sqlite.py
index 9631c1318..378ec7cd9 100644
--- a/lib/sqlalchemy/databases/sqlite.py
+++ b/lib/sqlalchemy/databases/sqlite.py
@@ -84,6 +84,8 @@ class SLBinary(sqltypes.Binary):
class SLBoolean(sqltypes.Boolean):
def get_col_spec(self):
return "BOOLEAN"
+ def convert_bind_param(self, value, dialect):
+ return value and 1 or 0
def convert_result_value(self, value, dialect):
if value is None:
return None
diff --git a/lib/sqlalchemy/orm/properties.py b/lib/sqlalchemy/orm/properties.py
index a0133bd0b..db34a9a2a 100644
--- a/lib/sqlalchemy/orm/properties.py
+++ b/lib/sqlalchemy/orm/properties.py
@@ -600,8 +600,13 @@ class EagerLoader(LazyLoader):
if hasattr(statement, '_outerjoin'):
towrap = statement._outerjoin
else:
- towrap = self.localparent.mapped_table
-
+ for (fromclause, finder) in [(x, sql_util.TableFinder(x)) for x in statement.froms]:
+ if self.localparent.mapped_table in finder:
+ towrap = fromclause
+ break
+ else:
+ raise exceptions.InvalidRequestError("EagerLoader cannot locate a clause with which to outer join to, in query '%s'" % str(statement))
+
if self.secondaryjoin is not None:
statement._outerjoin = sql.outerjoin(towrap, self.eagersecondary, self.eagerprimary).outerjoin(self.eagertarget, self.eagersecondaryjoin)
if self.order_by is False and self.secondary.default_order_by() is not None:
diff --git a/lib/sqlalchemy/sql.py b/lib/sqlalchemy/sql.py
index 9c04cdfcb..89688cbfe 100644
--- a/lib/sqlalchemy/sql.py
+++ b/lib/sqlalchemy/sql.py
@@ -1362,10 +1362,7 @@ class CompoundSelect(SelectBaseMixin, FromClause):
self.order_by(*kwargs.get('order_by', [None]))
self._col_map = {}
-# name = property(lambda s:s.keyword + " statement")
- def _foo(self):
- raise "this is a temporary assertion while we refactor SQL to not call 'name' on non-table Selectables"
- name = property(lambda s:s._foo()) #"SELECT statement")
+ name = property(lambda s:s.keyword + " statement")
def _locate_oid_column(self):
return self.selects[0].oid_column
@@ -1576,7 +1573,7 @@ class UpdateBase(ClauseElement):
"""forms the base for INSERT, UPDATE, and DELETE statements."""
def _process_colparams(self, parameters):
"""receives the "values" of an INSERT or UPDATE statement and constructs
- appropriate ind parameters."""
+ appropriate bind parameters."""
if parameters is None:
return None