1. idank
  2. sqlalchemy

Commits

Mike Bayer  committed b58833c

- added "FETCH" to the keywords detected by Postgres to indicate a result-row holding
statement (i.e. in addition to "SELECT").

  • Participants
  • Parent commits 8569f12
  • Branches default

Comments (0)

Files changed (2)

File CHANGES

View file
   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.
 

File lib/sqlalchemy/databases/postgres.py

View file
         ('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():