summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES3
-rw-r--r--lib/sqlalchemy/databases/postgres.py7
2 files changed, 10 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index a468ccc09..bdb2cd995 100644
--- a/CHANGES
+++ b/CHANGES
@@ -19,6 +19,9 @@ CHANGES
inheritance relationships need to be constructed in inheritance order
(which should be the normal case anyway).
+- added "FETCH" to the keywords detected by Postgres to indicate a result-row holding
+ statement (i.e. in addition to "SELECT").
+
- Added full list of SQLite reserved keywords so that they get escaped
properly.
diff --git a/lib/sqlalchemy/databases/postgres.py b/lib/sqlalchemy/databases/postgres.py
index f5eaf47f2..78f05954b 100644
--- a/lib/sqlalchemy/databases/postgres.py
+++ b/lib/sqlalchemy/databases/postgres.py
@@ -189,10 +189,17 @@ def descriptor():
('host',"Hostname", None),
]}
+SELECT_RE = re.compile(
+ r'\s*(?:SELECT|FETCH)',
+ re.I | re.UNICODE)
+
class PGExecutionContext(default.DefaultExecutionContext):
def _is_server_side(self):
return self.dialect.server_side_cursors and self.is_select() and not re.search(r'FOR UPDATE(?: NOWAIT)?\s*$', self.statement, re.I)
+
+ def is_select(self):
+ return SELECT_RE.match(self.statement)
def create_cursor(self):
if self._is_server_side():