From 76a0b6aa3aa7bd62c2a9ba11306c906047ee7ada Mon Sep 17 00:00:00 2001 From: Simon Charette Date: Sun, 12 Jan 2025 18:23:06 -0500 Subject: Refs #36050 -- Fixed OuterRef support for CompositePrimaryKey on Oracle. Oracle doesn't support native tuple comparison so each as_oracle implementation of tuple lookups must also perform right-hand-side sanitization. --- django/db/models/fields/tuple_lookups.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/django/db/models/fields/tuple_lookups.py b/django/db/models/fields/tuple_lookups.py index 2f195f25b9..ffab95a370 100644 --- a/django/db/models/fields/tuple_lookups.py +++ b/django/db/models/fields/tuple_lookups.py @@ -99,6 +99,8 @@ class TupleLookupMixin: class TupleExact(TupleLookupMixin, Exact): def as_oracle(self, compiler, connection): + # Process right-hand-side to trigger sanitization. + self.process_rhs(compiler, connection) # e.g.: (a, b, c) == (x, y, z) as SQL: # WHERE a = x AND b = y AND c = z lookups = [Exact(col, val) for col, val in zip(self.lhs, self.rhs)] @@ -131,6 +133,8 @@ class TupleIsNull(TupleLookupMixin, IsNull): class TupleGreaterThan(TupleLookupMixin, GreaterThan): def as_oracle(self, compiler, connection): + # Process right-hand-side to trigger sanitization. + self.process_rhs(compiler, connection) # e.g.: (a, b, c) > (x, y, z) as SQL: # WHERE a > x OR (a = x AND (b > y OR (b = y AND c > z))) lookups = itertools.cycle([GreaterThan, Exact]) @@ -157,6 +161,8 @@ class TupleGreaterThan(TupleLookupMixin, GreaterThan): class TupleGreaterThanOrEqual(TupleLookupMixin, GreaterThanOrEqual): def as_oracle(self, compiler, connection): + # Process right-hand-side to trigger sanitization. + self.process_rhs(compiler, connection) # e.g.: (a, b, c) >= (x, y, z) as SQL: # WHERE a > x OR (a = x AND (b > y OR (b = y AND (c > z OR c = z)))) lookups = itertools.cycle([GreaterThan, Exact]) @@ -183,6 +189,8 @@ class TupleGreaterThanOrEqual(TupleLookupMixin, GreaterThanOrEqual): class TupleLessThan(TupleLookupMixin, LessThan): def as_oracle(self, compiler, connection): + # Process right-hand-side to trigger sanitization. + self.process_rhs(compiler, connection) # e.g.: (a, b, c) < (x, y, z) as SQL: # WHERE a < x OR (a = x AND (b < y OR (b = y AND c < z))) lookups = itertools.cycle([LessThan, Exact]) @@ -209,6 +217,8 @@ class TupleLessThan(TupleLookupMixin, LessThan): class TupleLessThanOrEqual(TupleLookupMixin, LessThanOrEqual): def as_oracle(self, compiler, connection): + # Process right-hand-side to trigger sanitization. + self.process_rhs(compiler, connection) # e.g.: (a, b, c) <= (x, y, z) as SQL: # WHERE a < x OR (a = x AND (b < y OR (b = y AND (c < z OR c = z)))) lookups = itertools.cycle([LessThan, Exact]) -- cgit v1.3