From cf18eecd704f5eb6fde4e0c362cfdb322e3e559a Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 25 Nov 2007 03:28:49 +0000 Subject: - named_with_column becomes an attribute - cleanup within compiler visit_select(), column labeling - is_select() removed from dialects, replaced with returns_rows_text(), returns_rows_compiled() - should_autocommit() removed from dialects, replaced with should_autocommit_text() and should_autocommit_compiled() - typemap and column_labels collections removed from Compiler, replaced with single "result_map" collection. - ResultProxy uses more succinct logic in combination with result_map to target columns --- lib/sqlalchemy/databases/postgres.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'lib/sqlalchemy/databases/postgres.py') diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py index 88ac0e202..1cae31b53 100644 --- a/lib/sqlalchemy/databases/postgres.py +++ b/lib/sqlalchemy/databases/postgres.py @@ -233,16 +233,24 @@ RETURNING_QUOTED_RE = re.compile( class PGExecutionContext(default.DefaultExecutionContext): - def is_select(self): - m = SELECT_RE.match(self.statement) - return m and (not m.group(1) or (RETURNING_RE.search(self.statement) - and RETURNING_QUOTED_RE.match(self.statement))) + def returns_rows_text(self, statement): + m = SELECT_RE.match(statement) + return m and (not m.group(1) or (RETURNING_RE.search(statement) + and RETURNING_QUOTED_RE.match(statement))) + + def returns_rows_compiled(self, compiled): + return isinstance(compiled.statement, expression.Selectable) or \ + ( + (compiled.isupdate or compiled.isinsert) and "postgres_returning" in compiled.statement.kwargs + ) def create_cursor(self): # executing a default or Sequence standalone creates an execution context without a statement. # so slightly hacky "if no statement assume we're server side" logic + # TODO: dont use regexp if Compiled is used ? self.__is_server_side = \ - self.dialect.server_side_cursors and (self.statement is None or \ + self.dialect.server_side_cursors and \ + (self.statement is None or \ (SELECT_RE.match(self.statement) and not re.search(r'FOR UPDATE(?: NOWAIT)?\s*$', self.statement, re.I)) ) -- cgit v1.2.1