From 6d41f5e5edc54fec9f71540fbddb1197a862b9cc Mon Sep 17 00:00:00 2001 From: Mariusz Felisiak Date: Tue, 25 Oct 2022 20:01:25 +0200 Subject: [PATCH] Fixed DatabaseFeatures.supports_select_(intersection/difference) on MariaDB and MySQL 8.0.31+. --- django/db/backends/mysql/features.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/django/db/backends/mysql/features.py b/django/db/backends/mysql/features.py index d5641215caa..f2e4e1f1f4d 100644 --- a/django/db/backends/mysql/features.py +++ b/django/db/backends/mysql/features.py @@ -20,8 +20,6 @@ class DatabaseFeatures(BaseDatabaseFeatures): atomic_transactions = False can_clone_databases = True supports_temporal_subtraction = True - supports_select_intersection = False - supports_select_difference = False supports_slicing_ordering_in_compound = True supports_index_on_text_field = False supports_update_conflicts = True @@ -322,6 +320,15 @@ class DatabaseFeatures(BaseDatabaseFeatures): and self.connection.mysql_version >= (8, 0, 13) ) + @cached_property + def supports_select_intersection(self): + is_mariadb = self.connection.mysql_is_mariadb + return is_mariadb or self.connection.mysql_version >= (8, 0, 31) + + supports_select_difference = property( + operator.attrgetter("supports_select_intersection") + ) + @cached_property def can_rename_index(self): if self.connection.mysql_is_mariadb: