]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Add TRUNCATE to postgres autocommit regexp
authorJacob Hayes <jacob.r.hayes@gmail.com>
Fri, 15 Dec 2017 14:56:59 +0000 (09:56 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 18 Dec 2017 16:33:37 +0000 (11:33 -0500)
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)

doc/build/changelog/unreleased_11/pg_truncate.rst [new file with mode: 0644]
lib/sqlalchemy/dialects/postgresql/base.py
test/dialect/postgresql/test_dialect.py

diff --git a/doc/build/changelog/unreleased_11/pg_truncate.rst b/doc/build/changelog/unreleased_11/pg_truncate.rst
new file mode 100644 (file)
index 0000000..4720c28
--- /dev/null
@@ -0,0 +1,6 @@
+.. 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.
index e5f164d57317b613417b5aaeaa0429346f49014f..627a62f9afe56ae6c922e12e8649160c885818ef 100644 (file)
@@ -925,7 +925,7 @@ from sqlalchemy.types import INTEGER, BIGINT, SMALLINT, VARCHAR, \
 
 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(
index 5ab17ea8cd93ce3ba466f3ccee7a275c2efc044c..446765872e3da817cfcad5739a5eeb319e968252 100644 (file)
@@ -322,3 +322,6 @@ class AutocommitTextTest(test_execute.AutocommitTextTest):
 
     def test_revoke(self):
         self._test_keyword("REVOKE USAGE ON SCHEMA fooschema FROM foorole")
+
+    def test_truncate(self):
+        self._test_keyword("TRUNCATE footable")