Using MSSQL, getting this immediately after upgrading. I did it twice, so rolling back.
Logger: homeassistant.components.recorder
Source: components/recorder/util.py:116
Integration: Recorder (documentation, issues)
First occurred: 18:11:45 (1 occurrences)
Last logged: 18:11:45
Database error during schema migration
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1771, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 717, in do_execute
cursor.execute(statement, parameters)
pyodbc.ProgrammingError: ('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near '0'. (102) (SQLExecDirectW)")
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/recorder/__init__.py", line 735, in _migrate_schema_and_setup_run
migration.migrate_schema(self, current_version)
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 77, in migrate_schema
_apply_update(instance, session, new_version, current_version)
File "/usr/src/homeassistant/homeassistant/components/recorder/migration.py", line 562, in _apply_update
sum_statistics = get_metadata_with_session(
File "/usr/src/homeassistant/homeassistant/components/recorder/statistics.py", line 402, in get_metadata_with_session
result = execute(baked_query(session).params(statistic_ids=statistic_ids))
File "/usr/src/homeassistant/homeassistant/components/recorder/util.py", line 116, in execute
result = list(qry)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/ext/baked.py", line 382, in __iter__
return self._iter().__iter__()
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/ext/baked.py", line 412, in _iter
result = self.session.execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py", line 1689, in execute
result = conn._execute_20(statement, params or {}, execution_options)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1583, in _execute_20
return meth(self, args_10style, kwargs_10style, execution_options)
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/sql/elements.py", line 323, in _execute_on_connection
return connection._execute_clauseelement(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1452, in _execute_clauseelement
ret = self._execute_context(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1814, in _execute_context
self._handle_dbapi_exception(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1995, in _handle_dbapi_exception
util.raise_(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/util/compat.py", line 207, in raise_
raise exception
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/base.py", line 1771, in _execute_context
self.dialect.do_execute(
File "/usr/local/lib/python3.9/site-packages/sqlalchemy/engine/default.py", line 717, in do_execute
cursor.execute(statement, parameters)
sqlalchemy.exc.ProgrammingError: (pyodbc.ProgrammingError) ('42000', "[42000] [FreeTDS][SQL Server]Incorrect syntax near '0'. (102) (SQLExecDirectW)")
[SQL: SELECT statistics_meta.id AS statistics_meta_id, statistics_meta.statistic_id AS statistics_meta_statistic_id, statistics_meta.unit_of_measurement AS statistics_meta_unit_of_measurement, statistics_meta.has_mean AS statistics_meta_has_mean, statistics_meta.has_sum AS statistics_meta_has_sum
FROM statistics_meta
WHERE statistics_meta.has_sum IS NOT 0]
(Background on this error at: https://sqlalche.me/e/14/f405)