From c13eb665aadc3fdba694a47f6ae268b64696c70f Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 26 Sep 2007 20:32:19 +0000 Subject: [PATCH] - added "FETCH" to the keywords detected by Postgres to indicate a result-row holding statement (i.e. in addition to "SELECT"). --- CHANGES | 3 +++ lib/sqlalchemy/databases/postgres.py | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/CHANGES b/CHANGES index a468ccc096..bdb2cd9952 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 f5eaf47f21..78f05954b0 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(): -- 2.47.3