]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Support autocommit for GRANT and REVOKE on postgresql
authorJacob Hayes <jacob.r.hayes@gmail.com>
Mon, 8 May 2017 20:26:06 +0000 (16:26 -0400)
committerMike Bayer <mike_mp@zzzcomputing.com>
Tue, 9 May 2017 14:34:45 +0000 (10:34 -0400)
Extends `AUTOCOMMIT_REGEXP` for the postgres dialect to include `GRANT` and `REVOKE`.

Change-Id: Iba15f1ebf5bd7bc0fc1193fdf561417e53bf5d57
Pull-request: https://github.com/zzzeek/sqlalchemy/pull/357

doc/build/changelog/changelog_11.rst
lib/sqlalchemy/dialects/postgresql/base.py
test/dialect/postgresql/test_dialect.py

index 2a44a2f1007ee87392a2a710767f4c261ff5f67a..f284b5b00b69f46d87375282d7abce01219bc4a7 100644 (file)
         infrequently hitting a weakref that has not been fully acted upon
         after gc.
 
+    .. change::
+        :tags: bug, postgresql
+        :versions: 1.2.0b1
+
+        Added "autocommit" support for GRANT, REVOKE keywords.  Pull request
+        courtesy Jacob Hayes.
+
     .. change:: 3966
         :tags: bug, mysql
         :versions: 1.2.0b1
index b9c15ca2db577a8a1ae59bdac87862d23aac6a4c..2510bc975229e65f2a2059dafd83a13a4a4bae4f 100644 (file)
@@ -890,7 +890,7 @@ from sqlalchemy.types import INTEGER, BIGINT, SMALLINT, VARCHAR, \
     DATE, BOOLEAN, REAL
 
 AUTOCOMMIT_REGEXP = re.compile(
-    r'\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|'
+    r'\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|GRANT|REVOKE|'
     'IMPORT FOREIGN SCHEMA|REFRESH MATERIALIZED VIEW)',
     re.I | re.UNICODE)
 
index f03b48790d0273a7225f4beacf3a6425022b0d32..c79b186de074da872d21a2172e73fe2834ca1532 100644 (file)
@@ -304,8 +304,14 @@ class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
 class AutocommitTextTest(test_execute.AutocommitTextTest):
     __only_on__ = 'postgresql'
 
+    def test_grant(self):
+        self._test_keyword("GRANT USAGE ON SCHEMA fooschema TO foorole")
+
     def test_import_foreign_schema(self):
         self._test_keyword("IMPORT FOREIGN SCHEMA foob")
 
     def test_refresh_view(self):
         self._test_keyword("REFRESH MATERIALIZED VIEW fooview")
+
+    def test_revoke(self):
+        self._test_keyword("REVOKE USAGE ON SCHEMA fooschema FROM foorole")