Increase max bind vars based on database version (#101464)
This commit is contained in:
parent
c7d533d427
commit
da1d5fc862
13 changed files with 237 additions and 157 deletions
|
@ -10,7 +10,6 @@ from sqlalchemy.orm.session import Session
|
|||
from homeassistant.core import Event
|
||||
from homeassistant.util.json import JSON_ENCODE_EXCEPTIONS
|
||||
|
||||
from ..const import SQLITE_MAX_BIND_VARS
|
||||
from ..db_schema import EventData
|
||||
from ..queries import get_shared_event_datas
|
||||
from ..util import chunked, execute_stmt_lambda_element
|
||||
|
@ -95,7 +94,7 @@ class EventDataManager(BaseLRUTableManager[EventData]):
|
|||
"""
|
||||
results: dict[str, int | None] = {}
|
||||
with session.no_autoflush:
|
||||
for hashs_chunk in chunked(hashes, SQLITE_MAX_BIND_VARS):
|
||||
for hashs_chunk in chunked(hashes, self.recorder.max_bind_vars):
|
||||
for data_id, shared_data in execute_stmt_lambda_element(
|
||||
session, get_shared_event_datas(hashs_chunk), orm_rows=False
|
||||
):
|
||||
|
|
|
@ -9,7 +9,6 @@ from sqlalchemy.orm.session import Session
|
|||
|
||||
from homeassistant.core import Event
|
||||
|
||||
from ..const import SQLITE_MAX_BIND_VARS
|
||||
from ..db_schema import EventTypes
|
||||
from ..queries import find_event_type_ids
|
||||
from ..tasks import RefreshEventTypesTask
|
||||
|
@ -78,7 +77,7 @@ class EventTypeManager(BaseLRUTableManager[EventTypes]):
|
|||
return results
|
||||
|
||||
with session.no_autoflush:
|
||||
for missing_chunk in chunked(missing, SQLITE_MAX_BIND_VARS):
|
||||
for missing_chunk in chunked(missing, self.recorder.max_bind_vars):
|
||||
for event_type_id, event_type in execute_stmt_lambda_element(
|
||||
session, find_event_type_ids(missing_chunk), orm_rows=False
|
||||
):
|
||||
|
|
|
@ -11,7 +11,6 @@ from homeassistant.core import Event
|
|||
from homeassistant.helpers.entity import entity_sources
|
||||
from homeassistant.util.json import JSON_ENCODE_EXCEPTIONS
|
||||
|
||||
from ..const import SQLITE_MAX_BIND_VARS
|
||||
from ..db_schema import StateAttributes
|
||||
from ..queries import get_shared_attributes
|
||||
from ..util import chunked, execute_stmt_lambda_element
|
||||
|
@ -108,7 +107,7 @@ class StateAttributesManager(BaseLRUTableManager[StateAttributes]):
|
|||
"""
|
||||
results: dict[str, int | None] = {}
|
||||
with session.no_autoflush:
|
||||
for hashs_chunk in chunked(hashes, SQLITE_MAX_BIND_VARS):
|
||||
for hashs_chunk in chunked(hashes, self.recorder.max_bind_vars):
|
||||
for attributes_id, shared_attrs in execute_stmt_lambda_element(
|
||||
session, get_shared_attributes(hashs_chunk), orm_rows=False
|
||||
):
|
||||
|
|
|
@ -8,7 +8,6 @@ from sqlalchemy.orm.session import Session
|
|||
|
||||
from homeassistant.core import Event
|
||||
|
||||
from ..const import SQLITE_MAX_BIND_VARS
|
||||
from ..db_schema import StatesMeta
|
||||
from ..queries import find_all_states_metadata_ids, find_states_metadata_ids
|
||||
from ..util import chunked, execute_stmt_lambda_element
|
||||
|
@ -104,7 +103,7 @@ class StatesMetaManager(BaseLRUTableManager[StatesMeta]):
|
|||
update_cache = from_recorder or not self._did_first_load
|
||||
|
||||
with session.no_autoflush:
|
||||
for missing_chunk in chunked(missing, SQLITE_MAX_BIND_VARS):
|
||||
for missing_chunk in chunked(missing, self.recorder.max_bind_vars):
|
||||
for metadata_id, entity_id in execute_stmt_lambda_element(
|
||||
session, find_states_metadata_ids(missing_chunk)
|
||||
):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue