diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-25 03:28:49 +0000 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2007-11-25 03:28:49 +0000 |
| commit | cf18eecd704f5eb6fde4e0c362cfdb322e3e559a (patch) | |
| tree | 9b6e4503802cf0fcae9171b3ac2f85ba0af453c7 /lib/sqlalchemy/databases/postgres.py | |
| parent | 6f604f911640d92f705fc6611bfaa3e2600c4ee1 (diff) | |
| download | sqlalchemy-cf18eecd704f5eb6fde4e0c362cfdb322e3e559a.tar.gz | |
- 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
Diffstat (limited to 'lib/sqlalchemy/databases/postgres.py')
| -rw-r--r-- | lib/sqlalchemy/databases/postgres.py | 18 |
1 files changed, 13 insertions, 5 deletions
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)) ) |
