]> 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:09 +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

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 043efd6df5ea49c4ddebff9b755d8b320093c507..f1160425911528e3345717353a9876b7924689bf 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 29aa62e3fe49204657f8c9498682ca0e999b2662..3db7fef48b8b511107ca07e5ec6755baaaa8863d 100644 (file)
@@ -418,3 +418,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")