HasKey
This class provides the implementation for the 'has_key' lookup operator in PostgreSQL, utilizing the '?' operator. It is designed to check for the existence of a specific key within a JSONB or HSTORE column without preprocessing the right-hand side value.
Attributes
| Attribute | Type | Description |
|---|---|---|
| lookup_name | string = has_key | The name of the lookup used in Django querysets to identify this specific operator. |
| postgres_operator | string = ? | The specific PostgreSQL operator symbol used in the generated SQL query. |
| prepare_rhs | boolean = false | A flag indicating whether the right-hand side value should be processed by the compiler before being used in the query. |
Constructor
Signature
def HasKey() - > null
Methods
lookup_name()
def lookup_name() - > string
The identifier used in Django ORM queries to trigger the 'has_key' lookup.
Returns
| Type | Description |
|---|---|
string | The string 'has_key' used for filtering JSONB fields. |
postgres_operator()
def postgres_operator() - > string
The specific PostgreSQL operator used in the generated SQL query.
Returns
| Type | Description |
|---|---|
string | The '?' operator used to check if a top-level key exists in a JSONB column. |
prepare_rhs()
def prepare_rhs() - > boolean
A configuration flag indicating whether the right-hand side value should be processed by the compiler.
Returns
| Type | Description |
|---|---|
boolean | False, indicating the right-hand side value is used as-is without standard lookup preparation. |