From: Mike Bayer Date: Sat, 27 Oct 2007 17:41:30 +0000 (+0000) Subject: - removed regular expression step from most statement compilations. X-Git-Tag: rel_0_4_1~105 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a4daad81a6c5f987ac6eba0afdaccb3a70554f8;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git - removed regular expression step from most statement compilations. also fixes [ticket:833] - inlining on PG with_returning() call - extra options added for profiling --- diff --git a/CHANGES b/CHANGES index cbc67819f9..5e4c52b020 100644 --- a/CHANGES +++ b/CHANGES @@ -4,6 +4,8 @@ CHANGES 0.4.1 ----- +- removed regular expression step from most statement compilations. + also fixes [ticket:833] - Added test coverage for unknown type reflection, fixed sqlite/mysql handling of type reflection for unknown types. diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 018074b677..6449bdc144 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -648,27 +648,31 @@ class PGCompiler(compiler.DefaultCompiler): return super(PGCompiler, self).for_update_clause(select) def _append_returning(self, text, stmt): - returning_cols = stmt.kwargs.get('postgres_returning', None) - if returning_cols: - def flatten_columnlist(collist): - for c in collist: - if isinstance(c, expression.Selectable): - for co in c.columns: - yield co - else: - yield c - columns = [self.process(c) for c in flatten_columnlist(returning_cols)] - text += ' RETURNING ' + string.join(columns, ', ') - + returning_cols = stmt.kwargs['postgres_returning'] + def flatten_columnlist(collist): + for c in collist: + if isinstance(c, expression.Selectable): + for co in c.columns: + yield co + else: + yield c + columns = [self.process(c) for c in flatten_columnlist(returning_cols)] + text += ' RETURNING ' + string.join(columns, ', ') return text def visit_update(self, update_stmt): text = super(PGCompiler, self).visit_update(update_stmt) - return self._append_returning(text, update_stmt) + if 'postgres_returning' in update_stmt.kwargs: + return self._append_returning(text, update_stmt) + else: + return text def visit_insert(self, insert_stmt): text = super(PGCompiler, self).visit_insert(insert_stmt) - return self._append_returning(text, insert_stmt) + if 'postgres_returning' in insert_stmt.kwargs: + return self._append_returning(text, insert_stmt) + else: + return text class PGSchemaGenerator(compiler.SchemaGenerator): def get_column_specification(self, column, **kwargs): diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index f2627eb85f..e662f8e99d 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -43,6 +43,15 @@ BIND_PARAMS = re.compile(r'(?= assert_range[0] and stats.total_calls <= assert_range[1], stats.total_calls