diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-12-17 23:09:51 +0000 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2008-12-17 23:09:51 +0000 |
commit | 6a99f293130c6e11aba28c19c84f9195c5bf60c7 (patch) | |
tree | fec4da7bdcf1a3698f71eb24bda378249f3d56a4 /lib | |
parent | 7b7530de199963fc946b7f96c14bf78ae24a43a3 (diff) | |
download | sqlalchemy-6a99f293130c6e11aba28c19c84f9195c5bf60c7.tar.gz |
- _execute_clauseelement() goes back to being
a private method. Subclassing Connection
is not needed now that ConnectionProxy
is available.
- tightened the interface for the various _execute_XXX()
methods to reduce ambiguity
- __distill_params() no longer creates artificial [{}] entry,
blank dict is no longer passed through to do_execute()
in any case unless explicitly sent from the outside
as in connection.execute("somestring"), {})
- fixed a few old sql.query tests which were doing that
- removed needless do_execute() from mysql dialect
- fixed charset param not properly being sent to
_compat_fetchone() in mysql
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 7 | ||||
-rw-r--r-- | lib/sqlalchemy/engine/base.py | 26 | ||||
-rw-r--r-- | lib/sqlalchemy/sql/expression.py | 2 |
3 files changed, 16 insertions, 19 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 6a01b789b..0fc7c8fbd 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -1510,9 +1510,6 @@ class MySQLDialect(default.DefaultDialect): def supports_unicode_statements(self): return True - def do_execute(self, cursor, statement, parameters, context=None): - cursor.execute(statement, parameters) - def do_commit(self, connection): """Execute a COMMIT.""" @@ -1811,8 +1808,8 @@ class MySQLDialect(default.DefaultDialect): return row = _compat_fetchone( - connection.execute("SHOW VARIABLES LIKE 'sql_mode'", - charset=charset)) + connection.execute("SHOW VARIABLES LIKE 'sql_mode'"), + charset=charset) if not row: mode = '' else: diff --git a/lib/sqlalchemy/engine/base.py b/lib/sqlalchemy/engine/base.py index fc7fd9056..c7101d10e 100644 --- a/lib/sqlalchemy/engine/base.py +++ b/lib/sqlalchemy/engine/base.py @@ -497,7 +497,7 @@ class Connectable(object): def execute(self, object, *multiparams, **params): raise NotImplementedError() - def execute_clauseelement(self, elem, multiparams=None, params=None): + def _execute_clauseelement(self, elem, multiparams=None, params=None): raise NotImplementedError() class Connection(Connectable): @@ -833,7 +833,7 @@ class Connection(Connectable): if params: return [params] else: - return [{}] + return [] elif len(multiparams) == 1: zero = multiparams[0] if isinstance(zero, (list, tuple)): @@ -852,17 +852,17 @@ class Connection(Connectable): return [multiparams] def _execute_function(self, func, multiparams, params): - return self.execute_clauseelement(func.select(), multiparams, params) + return self._execute_clauseelement(func.select(), multiparams, params) - def _execute_default(self, default, multiparams=None, params=None): + def _execute_default(self, default, multiparams, params): return self.engine.dialect.defaultrunner(self.__create_execution_context()).traverse_single(default) - def execute_clauseelement(self, elem, multiparams=None, params=None): + def _execute_clauseelement(self, elem, multiparams, params): params = self.__distill_params(multiparams, params) if params: keys = params[0].keys() else: - keys = None + keys = [] context = self.__create_execution_context( compiled=elem.compile(dialect=self.dialect, column_keys=keys, inline=len(params) > 1), @@ -870,7 +870,7 @@ class Connection(Connectable): ) return self.__execute_context(context) - def _execute_compiled(self, compiled, multiparams=None, params=None): + def _execute_compiled(self, compiled, multiparams, params): """Execute a sql.Compiled object.""" context = self.__create_execution_context( @@ -955,7 +955,7 @@ class Connection(Connectable): # poor man's multimethod/generic function thingy executors = { expression._Function: _execute_function, - expression.ClauseElement: execute_clauseelement, + expression.ClauseElement: _execute_clauseelement, Compiled: _execute_compiled, schema.SchemaItem: _execute_default, schema.DDL: _execute_ddl, @@ -1128,7 +1128,7 @@ class Engine(Connectable): def _execute_default(self, default): connection = self.contextual_connect() try: - return connection._execute_default(default) + return connection._execute_default(default, (), {}) finally: connection.close() @@ -1196,9 +1196,9 @@ class Engine(Connectable): def scalar(self, statement, *multiparams, **params): return self.execute(statement, *multiparams, **params).scalar() - def execute_clauseelement(self, elem, multiparams=None, params=None): + def _execute_clauseelement(self, elem, multiparams=None, params=None): connection = self.contextual_connect(close_with_result=True) - return connection.execute_clauseelement(elem, multiparams, params) + return connection._execute_clauseelement(elem, multiparams, params) def _execute_compiled(self, compiled, multiparams, params): connection = self.contextual_connect(close_with_result=True) @@ -1273,7 +1273,7 @@ def _proxy_connection_cls(cls, proxy): def execute(self, object, *multiparams, **params): return proxy.execute(self, super(ProxyConnection, self).execute, object, *multiparams, **params) - def execute_clauseelement(self, elem, multiparams=None, params=None): + def _execute_clauseelement(self, elem, multiparams=None, params=None): return proxy.execute(self, super(ProxyConnection, self).execute, elem, *(multiparams or []), **(params or {})) def _cursor_execute(self, cursor, statement, parameters, context=None): @@ -1834,7 +1834,7 @@ class DefaultRunner(schema.SchemaVisitor): def exec_default_sql(self, default): conn = self.context.connection c = expression.select([default.arg]).compile(bind=conn) - return conn._execute_compiled(c).scalar() + return conn._execute_compiled(c, (), {}).scalar() def execute_string(self, stmt, params=None): """execute a string statement, using the raw cursor, and return a scalar result.""" diff --git a/lib/sqlalchemy/sql/expression.py b/lib/sqlalchemy/sql/expression.py index 6bda4c82c..aa0b7228c 100644 --- a/lib/sqlalchemy/sql/expression.py +++ b/lib/sqlalchemy/sql/expression.py @@ -1124,7 +1124,7 @@ class ClauseElement(Visitable): 'or the Metadata of its underlying tables to enable ' 'implicit execution via this method.' % label) raise exc.UnboundExecutionError(msg) - return e.execute_clauseelement(self, multiparams, params) + return e._execute_clauseelement(self, multiparams, params) def scalar(self, *multiparams, **params): """Compile and execute this ``ClauseElement``, returning the result's scalar representation.""" |