MCPcopy
hub / github.com/django/django / process_rhs

Method process_rhs

django/db/models/fields/json.py:605–627  ·  view source on GitHub ↗
(self, compiler, connection)

Source from the content-addressed store, hash-verified

603 # can_use_none_as_rhs = True
604
605 def process_rhs(self, compiler, connection):
606 if isinstance(self.rhs, KeyTransform):
607 return super(lookups.Exact, self).process_rhs(compiler, connection)
608 rhs, rhs_params = super().process_rhs(compiler, connection)
609 if connection.vendor == "oracle":
610 func = []
611 sql = "%s(JSON_OBJECT('value' VALUE %%s FORMAT JSON), '$.value')"
612 for value in rhs_params:
613 value = json.loads(value)
614 if isinstance(value, (list, dict)):
615 func.append(sql % "JSON_QUERY")
616 else:
617 func.append(sql % "JSON_VALUE")
618 rhs %= tuple(func)
619 elif connection.vendor == "sqlite":
620 func = []
621 for value in rhs_params:
622 if value in connection.ops.jsonfield_datatype_values:
623 func.append("%s")
624 else:
625 func.append("JSON_EXTRACT(%s, '$')")
626 rhs %= tuple(func)
627 return rhs, rhs_params
628
629 def as_oracle(self, compiler, connection):
630 rhs, rhs_params = super().process_rhs(compiler, connection)

Callers

nothing calls this directly

Calls 3

process_rhsMethod · 0.45
loadsMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected