Skip to main content

Overlap

This class provides a lookup implementation for the PostgreSQL overlap operator, represented by the double ampersand symbol. It facilitates checking whether two arrays or ranges share any common elements within a database query. The class automatically handles right-hand side subqueries by wrapping them in an array subquery expression during lookup preparation.

Attributes

AttributeTypeDescription
lookup_namestring = overlapThe identifier used in Django ORM queries to trigger this specific lookup, set to "overlap".
postgres_operatorstring = &&The specific PostgreSQL operator symbol used in the generated SQL to check if two arrays have elements in common.

Methods


get_prep_lookup()

@classmethod
def get_prep_lookup() - > Any

Prepares the right-hand side of the overlap lookup by wrapping subqueries in an ArraySubquery expression to ensure compatibility with Postgres array operators.

Returns

TypeDescription
AnyThe prepared lookup object ready for SQL compilation.