diff options
| author | Daniyal <abbasi.daniyal98@gmail.com> | 2021-03-24 11:15:08 +0530 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-07-15 11:43:33 +0200 |
| commit | f479df7f8d03ab767bb5e5d655243191087d6432 (patch) | |
| tree | bf6f248ad7938a0d9f77ea616a59fba2d5a8befb /django/db/models/sql | |
| parent | 08f077888548a951f01b454d0db08d9407f7f0aa (diff) | |
Refs #32508 -- Raised Type/ValueError instead of using "assert" in django.db.models.
Co-authored-by: Mariusz Felisiak <felisiak.mariusz@gmail.com>
Diffstat (limited to 'django/db/models/sql')
| -rw-r--r-- | django/db/models/sql/query.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py index 2412e6ad4e..b3d92d786c 100644 --- a/django/db/models/sql/query.py +++ b/django/db/models/sql/query.py @@ -567,14 +567,14 @@ class Query(BaseExpression): The 'connector' parameter describes how to connect filters from the 'rhs' query. """ - assert self.model == rhs.model, \ - "Cannot combine queries on two different base models." + if self.model != rhs.model: + raise TypeError('Cannot combine queries on two different base models.') if self.is_sliced: raise TypeError('Cannot combine queries once a slice has been taken.') - assert self.distinct == rhs.distinct, \ - "Cannot combine a unique query with a non-unique query." - assert self.distinct_fields == rhs.distinct_fields, \ - "Cannot combine queries with different distinct fields." + if self.distinct != rhs.distinct: + raise TypeError('Cannot combine a unique query with a non-unique query.') + if self.distinct_fields != rhs.distinct_fields: + raise TypeError('Cannot combine queries with different distinct fields.') # Work out how to relabel the rhs aliases, if necessary. change_map = {} |
