(self, compiler, connection, **extra_context)
| 33 | ) |
| 34 | |
| 35 | def as_postgresql(self, compiler, connection, **extra_context): |
| 36 | # Casting source expressions is only required using JSONB_BUILD_ARRAY |
| 37 | # or when using JSON_ARRAY on PostgreSQL 16+ with server-side bindings. |
| 38 | # This is done in all cases for consistency. |
| 39 | casted_obj = self.copy() |
| 40 | casted_obj.set_source_expressions( |
| 41 | [ |
| 42 | ( |
| 43 | # Conditional Cast to avoid unnecessary wrapping. |
| 44 | expression |
| 45 | if isinstance(expression, Cast) |
| 46 | else Cast(expression, expression.output_field) |
| 47 | ) |
| 48 | for expression in casted_obj.get_source_expressions() |
| 49 | ] |
| 50 | ) |
| 51 | |
| 52 | if connection.features.is_postgresql_16: |
| 53 | return casted_obj.as_native( |
| 54 | compiler, connection, returning="JSONB", **extra_context |
| 55 | ) |
| 56 | |
| 57 | return casted_obj.as_sql( |
| 58 | compiler, |
| 59 | connection, |
| 60 | function="JSONB_BUILD_ARRAY", |
| 61 | **extra_context, |
| 62 | ) |
| 63 | |
| 64 | def as_oracle(self, compiler, connection, **extra_context): |
| 65 | return self.as_native(compiler, connection, returning="CLOB", **extra_context) |
nothing calls this directly
no test coverage detected