From: Mike Bayer Date: Thu, 28 Sep 2006 04:53:00 +0000 (+0000) Subject: - added test suite to test improved from_obj/join behavior with Query/eagerloading... X-Git-Tag: rel_0_3_0~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fad6acf54241df43030d387c7c9ac3f54df3af5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - 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 --- diff --git a/CHANGES b/CHANGES index 8ed6d97720..8e1617c4ef 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 9631c13187..378ec7cd90 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 a0133bd0b6..db34a9a2ab 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 9c04cdfcb3..89688cbfe3 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