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
| Attribute | Type | Description |
|---|---|---|
| lookup_name | string = overlap | The identifier used in Django ORM queries to trigger this specific lookup, set to "overlap". |
| postgres_operator | string = && | 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
| Type | Description |
|---|---|
Any | The prepared lookup object ready for SQL compilation. |