.. changelog::
:version: 1.1.6
+ .. change:: 3804
+ :tags: bug, postgresql
+ :tickets: 3804
+
+ Added regular expressions for the "IMPORT FOREIGN SCHEMA",
+ "REFRESH MATERIALIZED VIEW" Postgresql statements so that they
+ autocommit when invoked via a connection or engine without
+ an explicit transaction. Pull requests courtesy Frazer McLean
+ and Paweł Stiasny.
+
.. change:: 3909
:tags: bug, orm
:tickets: 3909
CHAR, TEXT, FLOAT, NUMERIC, \
DATE, BOOLEAN, REAL
+AUTOCOMMIT_REGEXP = re.compile(
+ r'\s*(?:UPDATE|INSERT|CREATE|DELETE|DROP|ALTER|'
+ 'IMPORT FOREIGN SCHEMA|REFRESH MATERIALIZED VIEW)',
+ re.I | re.UNICODE)
+
RESERVED_WORDS = set(
["all", "analyse", "analyze", "and", "any", "array", "as", "asc",
"asymmetric", "both", "case", "cast", "check", "collate", "column",
return super(PGExecutionContext, self).get_insert_default(column)
+ def should_autocommit_text(self, statement):
+ return AUTOCOMMIT_REGEXP.match(statement)
+
class PGDialect(default.DefaultDialect):
name = 'postgresql'
from sqlalchemy.engine import url
from sqlalchemy.testing import is_
from sqlalchemy.testing import expect_deprecated
+from ...engine import test_execute
class MiscTest(fixtures.TestBase, AssertsExecutionResults, AssertsCompiledSQL):
ddl_compiler.get_column_specification(t.c.c),
"c %s NOT NULL" % expected
)
+
+
+class AutocommitTextTest(test_execute.AutocommitTextTest):
+ __only_on__ = 'postgresql'
+
+ 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")