Explorar o código

Removed definition of JSONObject ArgJoiner class in as_native function.

Sarah Boyce hai 4 meses
pai
achega
5c3b9d04d2
Modificáronse 1 ficheiros con 5 adicións e 6 borrados
  1. 5 6
      django/db/models/functions/comparison.py

+ 5 - 6
django/db/models/functions/comparison.py

@@ -160,16 +160,15 @@ class JSONObject(Func):
             )
         return super().as_sql(compiler, connection, **extra_context)
 
-    def as_native(self, compiler, connection, *, returning, **extra_context):
-        class ArgJoiner:
-            def join(self, args):
-                pairs = zip(args[::2], args[1::2], strict=True)
-                return ", ".join([" VALUE ".join(pair) for pair in pairs])
+    def join(self, args):
+        pairs = zip(args[::2], args[1::2], strict=True)
+        return ", ".join([" VALUE ".join(pair) for pair in pairs])
 
+    def as_native(self, compiler, connection, *, returning, **extra_context):
         return self.as_sql(
             compiler,
             connection,
-            arg_joiner=ArgJoiner(),
+            arg_joiner=self,
             template=f"%(function)s(%(expressions)s RETURNING {returning})",
             **extra_context,
         )