neosqlite.collection.expr_evaluator.sql_converters.date module¶
SQL converters for date operators.
- neosqlite.collection.expr_evaluator.sql_converters.date._validate_strftime_format(fmt: str) str[source]¶
Validate a MongoDB date format before strftime interpolation (#119).
Only known % specifiers and non-% characters pass; a single quote or an unknown specifier raises so the caller falls back to the Python tier instead of interpolating attacker-controlled text into SQL.
- class neosqlite.collection.expr_evaluator.sql_converters.date.DateMixin[source]¶
Bases:
BaseSqlMixin$year / $month / $dayOfMonth / $dateAdd / $dateSubtract / $dateDiff → SQL.
- _convert_date_operator(operator: str, operands: Any) tuple[str, list[Any]][source]¶
Convert date operators to SQL using strftime.
- _convert_date_arithmetic_operator(operator: str, operands: list[Any]) tuple[str, list[Any]][source]¶
Convert $dateAdd/$dateSubtract operators to SQL.
- MongoDB syntax: {$dateAdd: [date, amount, unit]} or
{$dateAdd: {startDate: date, amount: N, unit: “day”}}
SQLite: datetime(date, ‘+N unit’ or ‘-N unit’)
- _convert_date_diff_operator(operands: list[Any]) tuple[str, list[Any]][source]¶
Convert $dateDiff operator to SQL.
- MongoDB syntax: {$dateDiff: [date1, date2, unit]} or
{$dateDiff: {startDate: date1, endDate: date2, unit: “day”}}
SQLite: julianday(date2) - julianday(date1) for days
- _convert_date_to_string_operator(operands: Any) tuple[str, list[Any]][source]¶
Convert $dateToString to SQLite strftime().
- MongoDB: { $dateToString: { format: “%Y-%m-%d”, date: <expr> } }
or positional: [<format>, <date>]
- _convert_date_trunc_operator(operands: Any) tuple[str, list[Any]][source]¶
Convert $dateTrunc to SQLite strftime().
MongoDB: { $dateTrunc: { date: <expr>, unit: “hour” } }
- _convert_date_from_parts_operator(operands: Any) tuple[str, list[Any]][source]¶
Convert $dateFromParts to SQLite date construction.
MongoDB: { $dateFromParts: { year: <expr>, month: <expr>, … } }
- _convert_date_to_parts_operator(operands: Any) tuple[str, list[Any]][source]¶
Convert $dateToParts to SQLite strftime + json_object.
MongoDB: { $dateToParts: { date: <expr> } }
- _convert_date_from_string_operator(operands: Any) tuple[str, list[Any]][source]¶
Convert $dateFromString to SQLite strftime parsing.
MongoDB: { $dateFromString: { dateString: <expr> } }
SQLite strftime can parse ISO 8601 strings; non-ISO formats and timezone/onError/onNull options fall back to Python.