diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-06-26 10:22:39 -0400 |
|---|---|---|
| committer | Federico Caselli <cfederico87@gmail.com> | 2022-06-26 16:29:04 +0200 |
| commit | 815de6c3438ccba25b163eae2c34c5df7d82bf4d (patch) | |
| tree | 356a86c0a1e154d411f0793e6406d21260bd0415 /lib/sqlalchemy/sql | |
| parent | d608f62ec435ab790eb2a7dcfa672708195dc406 (diff) | |
| download | sqlalchemy-815de6c3438ccba25b163eae2c34c5df7d82bf4d.tar.gz | |
require at least one dialect name for variant
the call doesn't make sense otherwise
Fixes: #8179
Change-Id: I0e5dd584dc7090b536f9732cbfc6f3a5c8846dc5
Diffstat (limited to 'lib/sqlalchemy/sql')
| -rw-r--r-- | lib/sqlalchemy/sql/type_api.py | 11 |
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()" |
