diff options
| author | Federico Caselli <cfederico87@gmail.com> | 2020-08-22 00:30:44 +0200 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-22 12:46:12 -0400 |
| commit | 9ab4da7018eae8fc86430c24a38f8ffb0a5951ab (patch) | |
| tree | d6f9e401cbc24a3beb11a9fec56dd17f89cfe6fe /test/sql/test_sequences.py | |
| parent | 317f2e1be2b06cdc12bc84510eb743d9752763dd (diff) | |
| download | sqlalchemy-9ab4da7018eae8fc86430c24a38f8ffb0a5951ab.tar.gz | |
Updates for MariaDB sequences
MariaDB should not run a Sequence if it has optional=True.
Additionally, rework the rules in crud.py to accommodate the
new combination MariaDB brings us, which is a dialect
that supports both cursor.lastrowid, explicit sequences,
*and* no support for returning.
Co-authored-by: Mike Bayer <mike_mp@zzzcomputing.com>
Fixes: #5528
Change-Id: I9a8ea69a34983affa95dfd22186e2908fdf0d58c
Diffstat (limited to 'test/sql/test_sequences.py')
| -rw-r--r-- | test/sql/test_sequences.py | 31 |
1 files changed, 11 insertions, 20 deletions
diff --git a/test/sql/test_sequences.py b/test/sql/test_sequences.py index 8d894f9f3..ee7c77a93 100644 --- a/test/sql/test_sequences.py +++ b/test/sql/test_sequences.py @@ -231,38 +231,29 @@ class SequenceExecTest(fixtures.TestBase): connection.execute(t1.insert().values(x=s.next_value())) self._assert_seq_result(connection.scalar(t1.select())) - @testing.requires.no_lastrowid_support @testing.provide_metadata - def test_inserted_pk_no_returning_no_lastrowid(self): + def test_inserted_pk_no_returning(self): """test inserted_primary_key contains [None] when pk_col=next_value(), implicit returning is not used.""" + # I'm not really sure what this test wants to accomlish. + metadata = self.metadata t1 = Table("t", metadata, Column("x", Integer, primary_key=True)) - t1.create(testing.db) + s = Sequence("my_sequence_here", metadata=metadata) e = engines.testing_engine(options={"implicit_returning": False}) - s = Sequence("my_sequence") with e.connect() as conn: - r = conn.execute(t1.insert().values(x=s.next_value())) - eq_(r.inserted_primary_key, [None]) - @testing.requires.supports_lastrowid - @testing.requires.supports_lastrowid_for_expressions - @testing.provide_metadata - def test_inserted_pk_no_returning_w_lastrowid(self): - """test inserted_primary_key contains the pk when - pk_col=next_value(), lastrowid is supported.""" - - metadata = self.metadata - t1 = Table("t", metadata, Column("x", Integer, primary_key=True,),) - t1.create(testing.db) - e = engines.testing_engine(options={"implicit_returning": False}) - s = Sequence("my_sequence") + t1.create(conn) + s.create(conn) - with e.connect() as conn: r = conn.execute(t1.insert().values(x=s.next_value())) - self._assert_seq_result(r.inserted_primary_key[0]) + + if testing.requires.emulated_lastrowid_even_with_sequences.enabled: + eq_(r.inserted_primary_key, (1,)) + else: + eq_(r.inserted_primary_key, (None,)) @testing.requires.returning @testing.provide_metadata |
