]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
- added test suite to test improved from_obj/join behavior with Query/eagerloading...
authorMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Sep 2006 04:53:00 +0000 (04:53 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Thu, 28 Sep 2006 04:53:00 +0000 (04:53 +0000)
- 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

CHANGES
lib/sqlalchemy/databases/sqlite.py
lib/sqlalchemy/orm/properties.py
lib/sqlalchemy/sql.py

diff --git a/CHANGES b/CHANGES
index 8ed6d97720a563e87bc1e239321d3b9ff998356d..8e1617c4ef90b672a7f779b0184175945d15a125 100644 (file)
--- 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
index 9631c131871cca78b18da3e2bf1f30c4dfef4ffd..378ec7cd90608747c61c71d4bc9007905d695519 100644 (file)
@@ -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
index a0133bd0b6abcc5df00510f7bb69193a6f1074ed..db34a9a2abfe2f7e0828bb74bb668d841f19268f 100644 (file)
@@ -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:
index 9c04cdfcb36214ce81e85d4309879b135cda50fe..89688cbfe302466d5a1d2e5e6b3c5f3dade2ab35 100644 (file)
@@ -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