summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/dialects/mysql/provision.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-08-14 00:58:56 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-08-16 12:18:07 -0400
commitfc97854f69ee589774627f14ce78bb8a1bbb3236 (patch)
tree0a0fdb466d860e833461a06b25c4bc05d45be2ba /lib/sqlalchemy/dialects/mysql/provision.py
parent8a274e0058183cebeb37d3a5e7903209ce5e7c0e (diff)
downloadsqlalchemy-fc97854f69ee589774627f14ce78bb8a1bbb3236.tar.gz
Bump minimum MySQL version to 5.0.2; use all-numeric server version
MySQL dialect's server_version_info tuple is now all numeric. String tokens like "MariaDB" are no longer present so that numeric comparison works in all cases. The .is_mariadb flag on the dialect should be consulted for whether or not mariadb was detected. Additionally removed structures meant to support extremely old MySQL versions 3.x and 4.x; the minimum MySQL version supported is now version 5.0.2. In addition, as the "MariaDB" name goes away from server version, expand upon the change in I330815ebe572b6a9818377da56621397335fa702 to support the name "mariadb" throughout the dialect and test suite when mariadb-only mode is used. This changes the "name" field on the MariaDB dialect to "mariadb", which then implies a change throughout the testing requirements system as well as all the dialect-specific DDL argument names such as "mysql_engine" is now specified as "mariadb_engine", etc. Make use of the recent additions to test suite URL provisioning so that we can force MariaDB databases to have a "mariadb-only" dialect which allows us to test this name change fully. Update documentation to refer to MySQL / MariaDB explicitly as well as indicating the "mariadb_" prefix used for options. It seems likely that MySQL and MariaDB version numbers are going to start colliding at some point so having the "mariadb" name be available as a totally separate dialect name should give us some options in this regard. Currently also includes a date related fix to a test for the postgresql dialect that was implicitly assuming a non-UTC timezone Fixes: #4189 Change-Id: I00e76d00f62971e1f067bd61915fa6cc1cf64e5e
Diffstat (limited to 'lib/sqlalchemy/dialects/mysql/provision.py')
-rw-r--r--lib/sqlalchemy/dialects/mysql/provision.py31
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/sqlalchemy/dialects/mysql/provision.py b/lib/sqlalchemy/dialects/mysql/provision.py
index bf126464d..b86056da6 100644
--- a/lib/sqlalchemy/dialects/mysql/provision.py
+++ b/lib/sqlalchemy/dialects/mysql/provision.py
@@ -1,10 +1,33 @@
+import copy
+
+from ... import exc
from ...testing.provision import configure_follower
from ...testing.provision import create_db
from ...testing.provision import drop_db
+from ...testing.provision import generate_driver_url
from ...testing.provision import temp_table_keyword_args
-@create_db.for_db("mysql")
+@generate_driver_url.for_db("mysql", "mariadb")
+def generate_driver_url(url, driver):
+ backend = url.get_backend_name()
+
+ if backend == "mysql":
+ dialect_cls = url.get_dialect()
+ if dialect_cls._is_mariadb_from_url(url):
+ backend = "mariadb"
+
+ new_url = copy.copy(url)
+ new_url.drivername = "%s+%s" % (backend, driver)
+ try:
+ new_url.get_dialect()
+ except exc.NoSuchModuleError:
+ return None
+ else:
+ return new_url
+
+
+@create_db.for_db("mysql", "mariadb")
def _mysql_create_db(cfg, eng, ident):
with eng.connect() as conn:
try:
@@ -23,13 +46,13 @@ def _mysql_create_db(cfg, eng, ident):
)
-@configure_follower.for_db("mysql")
+@configure_follower.for_db("mysql", "mariadb")
def _mysql_configure_follower(config, ident):
config.test_schema = "%s_test_schema" % ident
config.test_schema_2 = "%s_test_schema_2" % ident
-@drop_db.for_db("mysql")
+@drop_db.for_db("mysql", "mariadb")
def _mysql_drop_db(cfg, eng, ident):
with eng.connect() as conn:
conn.exec_driver_sql("DROP DATABASE %s_test_schema" % ident)
@@ -37,6 +60,6 @@ def _mysql_drop_db(cfg, eng, ident):
conn.exec_driver_sql("DROP DATABASE %s" % ident)
-@temp_table_keyword_args.for_db("mysql")
+@temp_table_keyword_args.for_db("mysql", "mariadb")
def _mysql_temp_table_keyword_args(cfg, eng):
return {"prefixes": ["TEMPORARY"]}