Extends AUTOCOMMIT_REGEXP for the postgres dialect to include `TRUNCATE`.
Change-Id: I315e03674b89bb89aae669b8655481e4d890491e
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/407
(cherry picked from commit
756d5782870029f2d97b1aa171abd61dbf4cbcb4)
--- /dev/null
+.. change::
+ :tags: bug, postgresql
+
+ Added "TRUNCATE" to the list of keywords accepted by the
+ Postgresql dialect as an "autocommit"-triggering keyword.
+ Pull request courtesy Jacob Hayes.
AUTOCOMMIT_REGEXP = re.compile(
r'\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|GRANT|REVOKE|'
- 'IMPORT FOREIGN SCHEMA|REFRESH MATERIALIZED VIEW)',
+ 'IMPORT FOREIGN SCHEMA|REFRESH MATERIALIZED VIEW|TRUNCATE)',
re.I | re.UNICODE)
RESERVED_WORDS = set(
def test_revoke(self):
self._test_keyword("REVOKE USAGE ON SCHEMA fooschema FROM foorole")
+
+ def test_truncate(self):
+ self._test_keyword("TRUNCATE footable")