Skip to content

Commit

Permalink
Fix entity_id migration query failing with MySQL 8.0.30 (#90895)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Apr 6, 2023
1 parent 571204f commit 19f71b3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion homeassistant/components/recorder/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,8 @@ def batch_cleanup_entity_ids() -> StatementLambdaElement:
lambda: update(States)
.where(
States.state_id.in_(
select(States.state_id).join(
select(States.state_id)
.join(
states_with_entity_ids := select(
States.state_id.label("state_id_with_entity_id")
)
Expand All @@ -739,6 +740,8 @@ def batch_cleanup_entity_ids() -> StatementLambdaElement:
.subquery(),
States.state_id == states_with_entity_ids.c.state_id_with_entity_id,
)
.alias("states_with_entity_ids")
.select()
)
)
.values(entity_id=None)
Expand Down

0 comments on commit 19f71b3

Please sign in to comment.