From: Mike Bayer Date: Sat, 4 May 2019 17:25:25 +0000 (-0400) Subject: Further updates to CHECK logic X-Git-Tag: rel_1_0_11~17^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f6d70fb4b5ae83be2a41d2bb9d06e4438a55f94;p=thirdparty%2Fsqlalchemy%2Falembic.git Further updates to CHECK logic Change-Id: I5b0905df8d438eaa2a9665203f3d98a0db9c31f4 --- diff --git a/tests/requirements.py b/tests/requirements.py index 02b84f77..397b1622 100644 --- a/tests/requirements.py +++ b/tests/requirements.py @@ -150,14 +150,21 @@ class DefaultRequirements(SuiteRequirements): @property def check_constraint_reflection(self): return exclusions.fails_on_everything_except( - "postgresql", "sqlite", self._mariadb_102 + "postgresql", + "sqlite", + "oracle", + self._mysql_and_check_constraints_exist, ) @property def mysql_check_reflection_or_none(self): + # succeed if: + # 1. SQLAlchemy does not reflect CHECK constraints + # 2. SQLAlchemy does reflect CHECK constraints, but MySQL does not. def go(config): return ( - not self._mariadb_102(config) or self.sqlalchemy_1115.enabled + not self._mysql_check_constraints_exist(config) + or self.sqlalchemy_1115.enabled ) return exclusions.succeeds_if(go) @@ -180,6 +187,9 @@ class DefaultRequirements(SuiteRequirements): ) def mysql_check_col_name_change(self, config): + # MySQL has check constraints that enforce an reflect, however + # they prevent a column's name from being changed due to a bug in + # MariaDB 10.2 as well as MySQL 8.0.16 if exclusions.against(config, "mysql"): if sqla_compat._is_mariadb(config.db.dialect): mnvi = sqla_compat._mariadb_normalized_version_info @@ -193,17 +203,34 @@ class DefaultRequirements(SuiteRequirements): norm_version_info = config.db.dialect.server_version_info return norm_version_info >= (8, 0, 16) + else: + return True + + def _mysql_and_check_constraints_exist(self, config): + # 1. we have mysql / mariadb and + # 2. it enforces check constraints + if exclusions.against(config, "mysql"): + if sqla_compat._is_mariadb(config.db.dialect): + mnvi = sqla_compat._mariadb_normalized_version_info + norm_version_info = mnvi(config.db.dialect) + return norm_version_info >= (10, 2) + else: + norm_version_info = config.db.dialect.server_version_info + return norm_version_info >= (8, 0, 16) else: return False - return ( - exclusions.against(config, "mysql") - and sqla_compat._is_mariadb(config.db.dialect) - and sqla_compat._mariadb_normalized_version_info(config.db.dialect) - >= (10, 2) - and sqla_compat._mariadb_normalized_version_info(config.db.dialect) - < (10, 3) - ) + def _mysql_check_constraints_exist(self, config): + # 1. we dont have mysql / mariadb or + # 2. we have mysql / mariadb that enforces check constraints + return not exclusions.against( + config, "mysql" + ) or self._mysql_and_check_constraints_exist(config) + + def _mysql_check_constraints_dont_exist(self, config): + # 1. we have mysql / mariadb and + # 2. they dont enforce check constraints + return not self._mysql_check_constraints_exist(config) def _mysql_not_mariadb_102(self, config): return exclusions.against(config, "mysql") and (