mirror of
https://github.com/maziggy/bambuddy.git
synced 2026-09-30 11:12:35 +02:00
The hourly smart plug energy snapshot loop introduced with #941 crashed every cycle on PostgreSQL installs with: asyncpg.DataError: invalid input for query argument $2: datetime.datetime(..., tzinfo=datetime.timezone.utc) (can't subtract offset-naive and offset-aware datetimes) The engine has a `before_cursor_execute` hook that strips tzinfo from aware datetimes before they reach asyncpg (all schema datetime columns are TIMESTAMP WITHOUT TIME ZONE). The hook's `_strip_container` handled dict and tuple parameter containers but fell through `list` unchanged. When SQLAlchemy's insertmanyvalues feature batches two or more rows into a single INSERT ... SELECT FROM (VALUES ...) statement, it passes the positional params as a flat `list`, so the tz-aware datetimes survived the hook and reached asyncpg. Added a list branch that mirrors the tuple one. No schema change needed — the column stays naive UTC like the rest of the codebase. SQLite was never affected.