summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy
diff options
context:
space:
mode:
authorFederico Caselli <cfederico87@gmail.com>2022-06-26 15:34:13 +0000
committerGerrit Code Review <gerrit@ci3.zzzcomputing.com>2022-06-26 15:34:13 +0000
commitea1e64485ead04c45af5a322e78ce7b18d7cc773 (patch)
tree21c4fb014ccd1005c5aa660216e5ff6c8cb5f0f7 /lib/sqlalchemy
parent53d7f6be9b05efc6f4c8c8682c72dd59a4baf523 (diff)
parent815de6c3438ccba25b163eae2c34c5df7d82bf4d (diff)
downloadsqlalchemy-ea1e64485ead04c45af5a322e78ce7b18d7cc773.tar.gz
Merge "require at least one dialect name for variant" into main
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r--lib/sqlalchemy/sql/type_api.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py
index d8f1e92c4..46bf151ea 100644
--- a/lib/sqlalchemy/sql/type_api.py
+++ b/lib/sqlalchemy/sql/type_api.py
@@ -679,16 +679,17 @@ class TypeEngine(Visitable, Generic[_T]):
"""
+ if not dialect_names:
+ raise exc.ArgumentError("At least one dialect name is required")
for dialect_name in dialect_names:
if dialect_name in self._variant_mapping:
raise exc.ArgumentError(
- "Dialect '%s' is already present in "
- "the mapping for this %r" % (dialect_name, self)
+ f"Dialect {dialect_name!r} is already present in "
+ f"the mapping for this {self!r}"
)
new_type = self.copy()
- if isinstance(type_, type):
- type_ = type_()
- elif type_._variant_mapping:
+ type_ = to_instance(type_)
+ if type_._variant_mapping:
raise exc.ArgumentError(
"can't pass a type that already has variants as a "
"dialect-level type to with_variant()"