neosqlite.collection.temporary_table_aggregation.operators_match module¶
- class neosqlite.collection.temporary_table_aggregation.operators_match.OperatorsMatchMixin[source]¶
Bases:
OperatorsBaseMixin- _process_match_stage(create_temp: Callable, current_table: str, match_spec: dict[str, Any]) str[source]¶
Process a $match stage using temporary tables.
This method creates a temporary table that contains only documents matching the specified criteria. It translates the MongoDB-style match specification into SQL WHERE conditions using json_extract for field access.
The method supports these match operators: - $eq, $gt, $lt, $gte, $lte: Comparison operators - $in, $nin: Array membership operators - $ne: Not equal operator - $text: Text search operator (handled with special logic for unwound elements)
For the special _id field, it uses the table’s id column directly rather than json_extract.
- Parameters:
create_temp (Callable) – Function to create temporary tables
current_table (str) – Name of the current temporary table containing input data
match_spec (dict[str, Any]) – The $match stage specification
- Returns:
Name of the newly created temporary table with matched documents
- Return type:
str
- _process_unwind_stages(create_temp: Callable, current_table: str, unwind_specs: list[Any]) str[source]¶
Process one or more consecutive $unwind stages using temporary tables.
This method handles the $unwind stage which deconstructs an array field from input documents to output a document for each element. It can process either a single unwind stage or multiple consecutive unwind stages.
For a single unwind, it uses SQLite’s json_each function to expand the array into separate rows. For multiple consecutive unwinds, it processes them sequentially (one at a time) rather than trying to process them all together, which doesn’t work for nested arrays that depend on previous unwind operations.
The method properly handles array validation, ensuring that only documents with array fields are processed. It also supports the special _id field handling if it were to be unwound (though this would be unusual).
Supports these $unwind options: - path: The array field to unwind (required) - preserveNullAndEmptyArrays: If true, includes documents where the array is missing/null/empty - includeArrayIndex: If specified, includes the array index in the output
- Parameters:
create_temp (Callable) – Function to create temporary tables
current_table (str) – Name of the current temporary table containing input data
unwind_specs (list[Any]) – List of $unwind stage specifications to process consecutively
- Returns:
Name of the newly created temporary table with unwound documents
- Return type:
str
- Raises:
ValueError – If an invalid unwind specification is encountered