neosqlite.collection.query_helper.utils module¶
Utility functions for query helper operations.
- neosqlite.collection.query_helper.utils._check_sqlite_version(min_version: str) bool[source]¶
Check if the current SQLite version meets the minimum requirement.
- Parameters:
min_version (str) – Minimum version string (e.g., “3.42.0”)
- Returns:
True if requirements met, False otherwise
- Return type:
bool
- neosqlite.collection.query_helper.utils._supports_relative_json_indexing() bool[source]¶
Check if current SQLite version supports [#-N] relative indexing in JSON paths. Supported in SQLite 3.42.0 (2023-05-16) and later.
- Returns:
True if supported, False otherwise
- Return type:
bool
- neosqlite.collection.query_helper.utils._supports_returning_clause() bool[source]¶
Check if current SQLite supports RETURNING clause in DELETE/UPDATE statements.
This tests the feature at runtime rather than relying on version checks, as some SQLite builds may have features disabled at compile time.
RETURNING clause is supported in SQLite 3.35.0 (2021-03-12) and later.
- Returns:
True if supported, False otherwise
- Return type:
bool
- neosqlite.collection.query_helper.utils._get_json_function(name: str, jsonb_supported: bool) str[source]¶
Get the appropriate JSON function name based on JSONB support.
- Parameters:
name – The base function name (without json/jsonb prefix)
jsonb_supported – Whether JSONB functions are supported
- Returns:
The full function name with appropriate prefix
- Return type:
str
- neosqlite.collection.query_helper.utils._convert_bytes_to_binary(obj: Any) Any[source]¶
Recursively convert bytes objects to Binary objects in a document.
This function traverses a document structure (dict, list, etc.) and converts any bytes objects to Binary objects, which can be properly serialized to JSON. Existing Binary objects are left unchanged to preserve their subtype information.
- Parameters:
obj – The object to process (can be dict, list, bytes, Binary, or other types)
- Returns:
The processed object with bytes converted to Binary objects
- neosqlite.collection.query_helper.utils.set_force_fallback(force: bool = True) None[source]¶
Set global flag to force all aggregation queries to use Python fallback.
This function is useful for benchmarking and debugging to compare performance between the optimized SQL path and the Python fallback path.
- Parameters:
force (bool) – If True, forces all aggregation queries to use Python fallback. If False, allows normal optimization behavior.
- neosqlite.collection.query_helper.utils.get_force_fallback() bool[source]¶
Get the current state of the force fallback flag.
- Returns:
True if fallback is forced, False otherwise.
- Return type:
bool
- neosqlite.collection.query_helper.utils._validate_inc_mul_field_value(field_name: str, field_value: Any, operation: str) None[source]¶
Validate that a field value is appropriate for $inc or $mul operations.
- Parameters:
field_name – The name of the field being validated
field_value – The current value of the field
operation – The operation being performed (“$inc” or “$mul”)
- Raises:
MalformedQueryException – If the field value is not appropriate for the operation