Skip to main content

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

AttributeTypeDescription
lookup_namestring = has_keyThe name of the lookup used in Django querysets to identify this specific operator.
postgres_operatorstring = ?The specific PostgreSQL operator symbol used in the generated SQL query.
prepare_rhsboolean = falseA 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

TypeDescription
stringThe 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

TypeDescription
stringThe '?' 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

TypeDescription
booleanFalse, indicating the right-hand side value is used as-is without standard lookup preparation.