summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/build/changelog/unreleased_11/pg_truncate.rst6
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py2
-rw-r--r--test/dialect/postgresql/test_dialect.py3
3 files changed, 10 insertions, 1 deletions
diff --git a/doc/build/changelog/unreleased_11/pg_truncate.rst b/doc/build/changelog/unreleased_11/pg_truncate.rst
new file mode 100644
index 000000000..4720c288f
--- /dev/null
+++ b/doc/build/changelog/unreleased_11/pg_truncate.rst
@@ -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.
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index 043efd6df..f11604259 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -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(
diff --git a/test/dialect/postgresql/test_dialect.py b/test/dialect/postgresql/test_dialect.py
index 29aa62e3f..3db7fef48 100644
--- a/test/dialect/postgresql/test_dialect.py
+++ b/test/dialect/postgresql/test_dialect.py
@@ -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")