Types

Low-level type mapping utilities that convert Python type annotations to CQL type strings.

class coodie.types.CqlDuration(months: int = 0, days: int = 0, nanoseconds: int = 0)

Bases: object

Represents a CQL duration value.

CQL durations have three components that cannot be losslessly represented by datetime.timedelta because months have variable length.

Parameters:
  • months – Number of months.

  • days – Number of days.

  • nanoseconds – Number of nanoseconds.

months: int
days: int
nanoseconds: int
coodie.types.python_type_to_cql_type_str(annotation: Any) str

Map a Python type annotation to its CQL type string.

coodie.types.coerce_row_none_collections(doc_cls: type, row: dict[str, Any]) dict[str, Any]

Replace None values for collection-typed fields with empty collections.

Cassandra returns None for empty collections (list, set, map). Pydantic rejects None for non-optional collection fields, so we coerce them to the appropriate empty container before constructing the model.