From 88a9c956670333e3c41298bff869407b7f8b6854 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 19 Feb 2023 17:00:54 -0600 Subject: [PATCH] cleanup --- homeassistant/components/recorder/statistics.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/homeassistant/components/recorder/statistics.py b/homeassistant/components/recorder/statistics.py index 02e45472652..e0d02e8a0e3 100644 --- a/homeassistant/components/recorder/statistics.py +++ b/homeassistant/components/recorder/statistics.py @@ -16,7 +16,7 @@ import re from statistics import mean from typing import TYPE_CHECKING, Any, Literal, cast -from sqlalchemy import bindparam, func, lambda_stmt, select, text +from sqlalchemy import and_, bindparam, func, lambda_stmt, select, text from sqlalchemy.engine import Engine from sqlalchemy.engine.row import Row from sqlalchemy.exc import OperationalError, SQLAlchemyError, StatementError @@ -2022,9 +2022,10 @@ def _statistics_at_time( ) stmt = lambda_stmt(lambda: columns).join( most_recent_statistic_ids, - table.start_ts - == most_recent_statistic_ids.c.max_start_ts & table.metadata_id - == most_recent_statistic_ids.c.max_metadata_id, + and_( + table.start_ts == most_recent_statistic_ids.c.max_start_ts, + table.metadata_id == most_recent_statistic_ids.c.max_metadata_id, + ), ) return cast(Sequence[Row], execute_stmt_lambda_element(session, stmt))