neosqlite.collection.query_helper.helpers module

Helper functions for QueryHelper operations.

neosqlite.collection.query_helper.helpers._get_integer_id_for_oid(collection: Any, oid: Any) int[source]

Get the integer ID for a given ObjectId or other ID type.

This function delegates to the centralized get_integer_id_for_oid function to ensure consistent ID handling across all NeoSQLite components.

Parameters:
  • collection – The collection instance

  • oid – The ID value (can be ObjectId, int, str, etc.)

Returns:

The integer ID from the database

Return type:

int

neosqlite.collection.query_helper.helpers._validate_json_document(db: Any, json_str: str) bool[source]

Validate JSON document using SQLite’s json_valid function.

This method validates a JSON string using SQLite’s built-in json_valid function if available. For databases without JSON1 support, it falls back to Python’s json.loads for validation.

Parameters:
  • db – Database connection

  • json_str (str) – The JSON string to validate

Returns:

True if the JSON is valid, False otherwise

Return type:

bool

neosqlite.collection.query_helper.helpers._get_json_error_position(db: Any, json_str: str) int[source]

Get position of JSON error using json_error_position().

This method attempts to get the position of the first syntax error in a JSON string using SQLite’s json_error_position function if available. Returns -1 if the function is not supported or if the JSON is valid.

Parameters:
  • db – Database connection

  • json_str (str) – The JSON string to check for errors

Returns:

Position of the first syntax error, or -1 if valid/not supported

Return type:

int