summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/testing
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqlalchemy/testing')
-rw-r--r--lib/sqlalchemy/testing/requirements.py6
-rw-r--r--lib/sqlalchemy/testing/suite/test_insert.py28
2 files changed, 34 insertions, 0 deletions
diff --git a/lib/sqlalchemy/testing/requirements.py b/lib/sqlalchemy/testing/requirements.py
index 3a299b0db..d301dc69f 100644
--- a/lib/sqlalchemy/testing/requirements.py
+++ b/lib/sqlalchemy/testing/requirements.py
@@ -144,6 +144,12 @@ class SuiteRequirements(Requirements):
)
@property
+ def insert_from_select(self):
+ """target platform supports INSERT from a SELECT."""
+
+ return exclusions.open()
+
+ @property
def returning(self):
"""target platform supports RETURNING."""
diff --git a/lib/sqlalchemy/testing/suite/test_insert.py b/lib/sqlalchemy/testing/suite/test_insert.py
index a00fde312..ef05291b5 100644
--- a/lib/sqlalchemy/testing/suite/test_insert.py
+++ b/lib/sqlalchemy/testing/suite/test_insert.py
@@ -121,6 +121,34 @@ class InsertBehaviorTest(fixtures.TablesTest):
assert len(r.fetchall())
+ @requirements.insert_from_select
+ def test_insert_from_select(self):
+ table = self.tables.autoinc_pk
+ config.db.execute(
+ table.insert(),
+ [
+ dict(data="data1"),
+ dict(data="data2"),
+ dict(data="data3"),
+ ]
+ )
+
+
+ config.db.execute(
+ table.insert().
+ from_select(
+ ("data",), select([table.c.data]).where(
+ table.c.data.in_(["data2", "data3"]))
+ ),
+ )
+
+ eq_(
+ config.db.execute(
+ select([table.c.data]).order_by(table.c.data)
+ ).fetchall(),
+ [("data1", ), ("data2", ), ("data2", ),
+ ("data3", ), ("data3", )]
+ )
class ReturningTest(fixtures.TablesTest):
run_deletes = 'each'