Skip to main content

HasKeys

This class provides a lookup operator for PostgreSQL fields to determine if a collection contains a specific set of keys. It maps to the PostgreSQL "?&" operator and ensures that the right-hand side values are processed as a list of strings during the lookup preparation.

Attributes

AttributeTypeDescription
lookup_namestring = has_keysThe identifier used in Django ORM queries to invoke this specific lookup, set to "has_keys".
postgres_operatorstring = ?&The specific PostgreSQL operator used in the generated SQL to check if all specified keys exist in a JSONB column.

Constructor

Signature

def HasKeys()

Methods


get_prep_lookup()

@classmethod
def get_prep_lookup() - > list

Prepares the right-hand side values for the database query by converting each item in the collection to its string representation.

Returns

TypeDescription
listA list of strings representing the keys to be checked for existence within the JSONB field.