]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
#2629
authorMike Bayer <mike_mp@zzzcomputing.com>
Fri, 25 Jan 2013 17:57:59 +0000 (12:57 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Fri, 25 Jan 2013 17:57:59 +0000 (12:57 -0500)
insert().returning() raises an informative CompileError if attempted
to compile on a dialect that doesn't support RETURNING.

doc/build/changelog/changelog_08.rst
lib/sqlalchemy/sql/compiler.py
test/sql/test_compiler.py

index f6881f9583507e928d4eba214a8baa4e2923b3d9..e0303e2faf11a209767bd3ce5468b6557af025f4 100644 (file)
@@ -6,6 +6,13 @@
 .. changelog::
     :version: 0.8.0
 
+    .. change::
+        :tags: sql, bug
+        :tickets: 2629
+
+        insert().returning() raises an informative CompileError if attempted
+        to compile on a dialect that doesn't support RETURNING.
+
     .. change::
         :tags: orm, bug
         :tickets: 2655
index 152e68e34f1eacaf282b654c6386a1b905aef281..59e46de122d1574f5c6c5eb58aa16de57d27b97f 100644 (file)
@@ -1248,6 +1248,11 @@ class SQLCompiler(engine.Compiled):
         else:
             return ""
 
+    def returning_clause(self, stmt, returning_cols):
+        raise exc.CompileError(
+                    "RETURNING is not supported by this "
+                    "dialect's statement compiler.")
+
     def limit_clause(self, select):
         text = ""
         if select._limit is not None:
index e8fea2f7aaf7b9cb911adacf7ffd5f06096f7cf7..3b8aed23f6aca045853d60618a2e6c4dea196f7f 100644 (file)
@@ -2553,6 +2553,14 @@ class CRUDTest(fixtures.TestBase, AssertsCompiledSQL):
                     table.insert(inline=True),
                     "INSERT INTO sometable (foo) VALUES (foobar())", params={})
 
+    def test_insert_returning_not_in_default(self):
+        stmt = table1.insert().returning(table1.c.myid)
+        assert_raises_message(
+            exc.CompileError,
+            "RETURNING is not supported by this dialect's statement compiler.",
+            stmt.compile
+        )
+
     def test_empty_insert_default(self):
         stmt = table1.insert().values({})  # hide from 2to3
         self.assert_compile(stmt, "INSERT INTO mytable () VALUES ()")