(self, compiler, connection, *, returning, **extra_context)
| 17 | return super().as_sql(compiler, connection, **extra_context) |
| 18 | |
| 19 | def as_native(self, compiler, connection, *, returning, **extra_context): |
| 20 | # PostgreSQL 16+ and Oracle remove SQL NULL values from the array by |
| 21 | # default. Adds the NULL ON NULL clause to keep NULL values in the |
| 22 | # array, mapping them to JSON null values, which matches the behavior |
| 23 | # of SQLite. |
| 24 | null_on_null = "NULL ON NULL" if len(self.get_source_expressions()) > 0 else "" |
| 25 | |
| 26 | return self.as_sql( |
| 27 | compiler, |
| 28 | connection, |
| 29 | template=( |
| 30 | f"%(function)s(%(expressions)s {null_on_null} RETURNING {returning})" |
| 31 | ), |
| 32 | **extra_context, |
| 33 | ) |
| 34 | |
| 35 | def as_postgresql(self, compiler, connection, **extra_context): |
| 36 | # Casting source expressions is only required using JSONB_BUILD_ARRAY |
no test coverage detected