diff --git a/homeassistant/components/recorder/purge.py b/homeassistant/components/recorder/purge.py index 230084d1bd25c..e3a3f1ff7cc19 100644 --- a/homeassistant/components/recorder/purge.py +++ b/homeassistant/components/recorder/purge.py @@ -36,7 +36,7 @@ def _generate_find_attr_lambda() -> StatementLambdaElement: return lambda_stmt( lambda: union_all( *[ - select(func.min(States.attributes_id).label("id")).where( + select(func.min(States.attributes_id)).where( States.attributes_id == bindparam(f"a{idx}", required=False) ) for idx in range( diff --git a/tests/components/recorder/test_purge.py b/tests/components/recorder/test_purge.py index 5485749043448..129477a93dac2 100644 --- a/tests/components/recorder/test_purge.py +++ b/tests/components/recorder/test_purge.py @@ -42,7 +42,7 @@ def _generate_sqlite_compatible_find_attr_lambda() -> StatementLambdaElement: return lambda_stmt( lambda: union_all( *[ - select(func.min(States.attributes_id).label("id")).where( + select(func.min(States.attributes_id)).where( States.attributes_id == bindparam(f"a{idx}", required=False) ) for idx in range(