neosqlite.collection.query_helper.update_operations module

Update operations for QueryHelper.

Dispatches between SQL-based and Python-based update paths. The SQL implementation lives in _sql_updates.py (SqlUpdatesMixin).

class neosqlite.collection.query_helper.update_operations.UpdateOperationsMixin[source]

Bases: SqlUpdatesMixin

A mixin class providing update operations for QueryHelper.

This mixin assumes it will be used with a class that has: - self.collection (with db and name attributes) - self.jsonb.jsonb_supported - self.jsonb.json_function_prefix - self._build_simple_where_clause method

collection: Collection
jsonb: JSONBContext
_get_integer_id_for_oid: Any
_internal_update(doc_id: Any, update_spec: dict[str, Any], original_doc: dict[str, Any], array_filters: list[dict[str, Any]] | None = None, query_filter: dict[str, Any] | None = None) tuple[dict[str, Any], bool][source]

Helper method for updating documents.

Attempts to use SQL-based updates for simple operations, falling back to Python-based updates for complex operations.

Parameters:
  • doc_id (Any) – The ID of the document to update (can be ObjectId, int, etc.).

  • update_spec (dict[str, Any]) – The update specification.

  • original_doc (dict[str, Any]) – The original document before the update.

  • array_filters (list[dict[str, Any]], optional) – Filter documents for array positional operators.

  • query_filter (dict[str, Any], optional) – The query filter for $ operator.

Returns:

The updated document and whether it was modified.

Return type:

tuple[dict[str, Any], bool]

_perform_python_update(doc_id: Any, update_spec: dict[str, Any], original_doc: dict[str, Any], array_filters: list[dict[str, Any]] | None = None, query_filter: dict[str, Any] | None = None) tuple[dict[str, Any], bool][source]

Perform update operations using Python-based logic.

Parameters:
  • doc_id (Any) – The document ID of the document to update (can be ObjectId, int, etc.).

  • update_spec (dict[str, Any]) – A dictionary specifying the update operations to perform.

  • original_doc (dict[str, Any]) – The original document before applying the updates.

  • array_filters (list[dict[str, Any]], optional) – Filter documents for array positional operators.

  • query_filter (dict[str, Any], optional) – The query filter for $ operator.

Returns:

The updated document and whether it was modified.

Return type:

tuple[dict[str, Any], bool]