Skip to content

Commit

Permalink
Reduce sqlalchemy reflection overhead at recorder setup time (#113989)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco committed Mar 23, 2024
1 parent 7b0abb0 commit de62b77
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions homeassistant/components/recorder/auto_repairs/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import logging
from typing import TYPE_CHECKING

from sqlalchemy import MetaData
from sqlalchemy import MetaData, Table
from sqlalchemy.exc import OperationalError
from sqlalchemy.orm import DeclarativeBase
from sqlalchemy.orm.attributes import InstrumentedAttribute
Expand Down Expand Up @@ -94,9 +94,9 @@ def _validate_table_schema_has_correct_collation(
with session_scope(session=instance.get_session(), read_only=True) as session:
table = table_object.__tablename__
metadata_obj = MetaData()
reflected_table = Table(table, metadata_obj, autoload_with=instance.engine)
connection = session.connection()
metadata_obj.reflect(bind=connection)
dialect_kwargs = metadata_obj.tables[table].dialect_kwargs
dialect_kwargs = reflected_table.dialect_kwargs
# Check if the table has a collation set, if its not set than its
# using the server default collation for the database

Expand Down

0 comments on commit de62b77

Please sign in to comment.