diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-12 18:46:25 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-08-13 14:25:44 -0400 |
commit | cd03b8f0cecbf72ecd6c99c4d3a6338c8278b40d (patch) | |
tree | 32b50cef944f41b1cfd5bd7b0dfd45af448e793b /test/dialect/mysql/test_compiler.py | |
parent | 65da69910944ccbad0c6d008b94ae8271aae4762 (diff) | |
download | sqlalchemy-cd03b8f0cecbf72ecd6c99c4d3a6338c8278b40d.tar.gz |
Use importlib_metadata; add namespace for mariadb
The ``importlib_metadata`` library is used to scan for setuptools
entrypoints rather than pkg_resources. as importlib_metadata is a small
library that is included as of Python 3.8, the compatibility library is
installed as a dependency for Python versions older than 3.8.
Unfortunately setuptools "attr:" is broken because it tries to import
the module; seems like this is fixed as part of
https://github.com/pypa/setuptools/pull/1753 however this is too recent
to rely upon for now.
Added a new dialect token "mariadb" that may be used in place of "mysql" in
the :func:`_sa.create_engine` URL. This will deliver a MariaDB dialect
subclass of the MySQLDialect in use that forces the "is_mariadb" flag to
True. The dialect will raise an error if a server version string that does
not indicate MariaDB in use is received. This is useful for
MariaDB-specific testing scenarios as well as to support applications that
are hardcoding to MariaDB-only concepts. As MariaDB and MySQL featuresets
and usage patterns continue to diverge, this pattern may become more
prominent.
Fixes: #5400
Fixes: #5496
Change-Id: I330815ebe572b6a9818377da56621397335fa702
Diffstat (limited to 'test/dialect/mysql/test_compiler.py')
-rw-r--r-- | test/dialect/mysql/test_compiler.py | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/test/dialect/mysql/test_compiler.py b/test/dialect/mysql/test_compiler.py index 09bdd80be..2053318b6 100644 --- a/test/dialect/mysql/test_compiler.py +++ b/test/dialect/mysql/test_compiler.py @@ -150,13 +150,11 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): constraint_name = "constraint" constraint = CheckConstraint("data IS NOT NULL", name=constraint_name) Table(table_name, m, Column("data", String(255)), constraint) - dialect = mysql.dialect() - dialect.server_version_info = (10, 1, 1, "MariaDB") self.assert_compile( schema.DropConstraint(constraint), "ALTER TABLE %s DROP CONSTRAINT `%s`" % (table_name, constraint_name), - dialect=dialect, + dialect="mariadb", ) def test_create_index_with_length_quoted(self): @@ -354,8 +352,6 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): self.assert_compile(expr, "concat('x', 'y')", literal_binds=True) def test_mariadb_for_update(self): - dialect = mysql.dialect() - dialect.server_version_info = (10, 1, 1, "MariaDB") table1 = table( "mytable", column("myid"), column("name"), column("description") @@ -366,7 +362,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "SELECT mytable.myid, mytable.name, mytable.description " "FROM mytable WHERE mytable.myid = %s " "FOR UPDATE", - dialect=dialect, + dialect="mariadb", ) self.assert_compile( @@ -376,7 +372,7 @@ class CompileTest(fixtures.TestBase, AssertsCompiledSQL): "SELECT mytable.myid, mytable.name, mytable.description " "FROM mytable WHERE mytable.myid = %s " "FOR UPDATE", - dialect=dialect, + dialect="mariadb", ) def test_delete_extra_froms(self): |