diff options
Diffstat (limited to 'django/db/models/fields/json.py')
| -rw-r--r-- | django/db/models/fields/json.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/django/db/models/fields/json.py b/django/db/models/fields/json.py index b82c6a82e2..7199d86e04 100644 --- a/django/db/models/fields/json.py +++ b/django/db/models/fields/json.py @@ -140,28 +140,30 @@ class DataContains(PostgresOperatorLookup): postgres_operator = '@>' def as_sql(self, compiler, connection): + if not connection.features.supports_json_field_contains: + raise NotSupportedError( + 'contains lookup is not supported on this database backend.' + ) lhs, lhs_params = self.process_lhs(compiler, connection) rhs, rhs_params = self.process_rhs(compiler, connection) params = tuple(lhs_params) + tuple(rhs_params) return 'JSON_CONTAINS(%s, %s)' % (lhs, rhs), params - def as_oracle(self, compiler, connection): - raise NotSupportedError('contains lookup is not supported on Oracle.') - class ContainedBy(PostgresOperatorLookup): lookup_name = 'contained_by' postgres_operator = '<@' def as_sql(self, compiler, connection): + if not connection.features.supports_json_field_contains: + raise NotSupportedError( + 'contained_by lookup is not supported on this database backend.' + ) lhs, lhs_params = self.process_lhs(compiler, connection) rhs, rhs_params = self.process_rhs(compiler, connection) params = tuple(rhs_params) + tuple(lhs_params) return 'JSON_CONTAINS(%s, %s)' % (rhs, lhs), params - def as_oracle(self, compiler, connection): - raise NotSupportedError('contained_by lookup is not supported on Oracle.') - class HasKeyLookup(PostgresOperatorLookup): logical_operator = None |
