summaryrefslogtreecommitdiff
path: root/test/engine
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2019-11-21 09:43:40 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-11-26 11:06:37 -0500
commit6f99bdf013f3a0637f0544c4c3daeac0392553d6 (patch)
tree806937a8f44eddd254e41ed7597371a87d2108fa /test/engine
parentd933ddd503a1ca0a7c562c51c503139c541e707e (diff)
downloadsqlalchemy-6f99bdf013f3a0637f0544c4c3daeac0392553d6.tar.gz
Add sequence support for MariaDB 10.3+.
Added support for use of the :class:`.Sequence` construct with MariaDB 10.3 and greater, as this is now supported by this database. The construct integrates with the :class:`.Table` object in the same way that it does for other databases like PostrgreSQL and Oracle; if is present on the integer primary key "autoincrement" column, it is used to generate defaults. For backwards compatibility, to support a :class:`.Table` that has a :class:`.Sequence` on it to support sequence only databases like Oracle, while still not having the sequence fire off for MariaDB, the optional=True flag should be set, which indicates the sequence should only be used to generate the primary key if the target database offers no other option. Fixes: #4976 Closes: #4996 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/4996 Pull-request-sha: cb2e1426ea0b6bc6c93dbe8f033a11df9d8c4915 Change-Id: I507bc405eee6cae2c5991345d0eac53a37fe7512
Diffstat (limited to 'test/engine')
-rw-r--r--test/engine/test_execute.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/test/engine/test_execute.py b/test/engine/test_execute.py
index 652cea3f3..b71eb8837 100644
--- a/test/engine/test_execute.py
+++ b/test/engine/test_execute.py
@@ -1761,16 +1761,23 @@ class EngineEventsTest(fixtures.TestBase):
implicit_returning=False,
)
self.metadata.create_all(engine)
+
with engine.begin() as conn:
event.listen(
conn, "before_cursor_execute", tracker("cursor_execute")
)
conn.execute(t.insert())
- # we see the sequence pre-executed in the first call
- assert "t_id_seq" in canary[0][0]
- assert "INSERT" in canary[1][0]
- # same context
- is_(canary[0][1], canary[1][1])
+
+ if testing.requires.supports_lastrowid.enabled:
+ # new MariaDB 10.3 supports sequences + lastrowid; only
+ # one statement
+ assert "INSERT" in canary[0][0]
+ else:
+ # we see the sequence pre-executed in the first call
+ assert "t_id_seq" in canary[0][0]
+ assert "INSERT" in canary[1][0]
+ # same context
+ is_(canary[0][1], canary[1][1])
def test_transactional(self):
canary = []