mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Bump SQLAlchemy to 2.0.39 (#140473)
* Bump SQLAlchemy to 2.0.39 changelog: https://docs.sqlalchemy.org/en/20/changelog/changelog_20.html#change-2.0.39 * fix typing
This commit is contained in:
parent
1f6658fca0
commit
e78dc486f7
@ -203,11 +203,11 @@ UINT_32_TYPE = BigInteger().with_variant(
|
|||||||
"mariadb",
|
"mariadb",
|
||||||
)
|
)
|
||||||
JSON_VARIANT_CAST = Text().with_variant(
|
JSON_VARIANT_CAST = Text().with_variant(
|
||||||
postgresql.JSON(none_as_null=True), # type: ignore[no-untyped-call]
|
postgresql.JSON(none_as_null=True),
|
||||||
"postgresql",
|
"postgresql",
|
||||||
)
|
)
|
||||||
JSONB_VARIANT_CAST = Text().with_variant(
|
JSONB_VARIANT_CAST = Text().with_variant(
|
||||||
postgresql.JSONB(none_as_null=True), # type: ignore[no-untyped-call]
|
postgresql.JSONB(none_as_null=True),
|
||||||
"postgresql",
|
"postgresql",
|
||||||
)
|
)
|
||||||
DATETIME_TYPE = (
|
DATETIME_TYPE = (
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"iot_class": "local_push",
|
"iot_class": "local_push",
|
||||||
"quality_scale": "internal",
|
"quality_scale": "internal",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"SQLAlchemy==2.0.38",
|
"SQLAlchemy==2.0.39",
|
||||||
"fnv-hash-fast==1.4.0",
|
"fnv-hash-fast==1.4.0",
|
||||||
"psutil-home-assistant==0.0.1"
|
"psutil-home-assistant==0.0.1"
|
||||||
]
|
]
|
||||||
|
@ -9,7 +9,7 @@ from dataclasses import dataclass, replace as dataclass_replace
|
|||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from time import time
|
from time import time
|
||||||
from typing import TYPE_CHECKING, Any, cast, final
|
from typing import TYPE_CHECKING, Any, TypedDict, cast, final
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
|
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
@ -712,6 +712,11 @@ def _modify_columns(
|
|||||||
raise
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
class _FKAlterDict(TypedDict):
|
||||||
|
old_fk: ForeignKeyConstraint
|
||||||
|
columns: list[str]
|
||||||
|
|
||||||
|
|
||||||
def _update_states_table_with_foreign_key_options(
|
def _update_states_table_with_foreign_key_options(
|
||||||
session_maker: Callable[[], Session], engine: Engine
|
session_maker: Callable[[], Session], engine: Engine
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -729,7 +734,7 @@ def _update_states_table_with_foreign_key_options(
|
|||||||
|
|
||||||
inspector = sqlalchemy.inspect(engine)
|
inspector = sqlalchemy.inspect(engine)
|
||||||
tmp_states_table = Table(TABLE_STATES, MetaData())
|
tmp_states_table = Table(TABLE_STATES, MetaData())
|
||||||
alters = [
|
alters: list[_FKAlterDict] = [
|
||||||
{
|
{
|
||||||
"old_fk": ForeignKeyConstraint(
|
"old_fk": ForeignKeyConstraint(
|
||||||
(), (), name=foreign_key["name"], table=tmp_states_table
|
(), (), name=foreign_key["name"], table=tmp_states_table
|
||||||
@ -755,14 +760,14 @@ def _update_states_table_with_foreign_key_options(
|
|||||||
with session_scope(session=session_maker()) as session:
|
with session_scope(session=session_maker()) as session:
|
||||||
try:
|
try:
|
||||||
connection = session.connection()
|
connection = session.connection()
|
||||||
connection.execute(DropConstraint(alter["old_fk"])) # type: ignore[no-untyped-call]
|
connection.execute(DropConstraint(alter["old_fk"]))
|
||||||
for fkc in states_key_constraints:
|
for fkc in states_key_constraints:
|
||||||
if fkc.column_keys == alter["columns"]:
|
if fkc.column_keys == alter["columns"]:
|
||||||
# AddConstraint mutates the constraint passed to it, we need to
|
# AddConstraint mutates the constraint passed to it, we need to
|
||||||
# undo that to avoid changing the behavior of the table schema.
|
# undo that to avoid changing the behavior of the table schema.
|
||||||
# https://github.com/sqlalchemy/sqlalchemy/blob/96f1172812f858fead45cdc7874abac76f45b339/lib/sqlalchemy/sql/ddl.py#L746-L748
|
# https://github.com/sqlalchemy/sqlalchemy/blob/96f1172812f858fead45cdc7874abac76f45b339/lib/sqlalchemy/sql/ddl.py#L746-L748
|
||||||
create_rule = fkc._create_rule # noqa: SLF001
|
create_rule = fkc._create_rule # noqa: SLF001
|
||||||
add_constraint = AddConstraint(fkc) # type: ignore[no-untyped-call]
|
add_constraint = AddConstraint(fkc)
|
||||||
fkc._create_rule = create_rule # noqa: SLF001
|
fkc._create_rule = create_rule # noqa: SLF001
|
||||||
connection.execute(add_constraint)
|
connection.execute(add_constraint)
|
||||||
except (InternalError, OperationalError):
|
except (InternalError, OperationalError):
|
||||||
@ -800,7 +805,7 @@ def _drop_foreign_key_constraints(
|
|||||||
with session_scope(session=session_maker()) as session:
|
with session_scope(session=session_maker()) as session:
|
||||||
try:
|
try:
|
||||||
connection = session.connection()
|
connection = session.connection()
|
||||||
connection.execute(DropConstraint(drop)) # type: ignore[no-untyped-call]
|
connection.execute(DropConstraint(drop))
|
||||||
except (InternalError, OperationalError):
|
except (InternalError, OperationalError):
|
||||||
_LOGGER.exception(
|
_LOGGER.exception(
|
||||||
"Could not drop foreign constraints in %s table on %s",
|
"Could not drop foreign constraints in %s table on %s",
|
||||||
@ -845,7 +850,7 @@ def _restore_foreign_key_constraints(
|
|||||||
# undo that to avoid changing the behavior of the table schema.
|
# undo that to avoid changing the behavior of the table schema.
|
||||||
# https://github.com/sqlalchemy/sqlalchemy/blob/96f1172812f858fead45cdc7874abac76f45b339/lib/sqlalchemy/sql/ddl.py#L746-L748
|
# https://github.com/sqlalchemy/sqlalchemy/blob/96f1172812f858fead45cdc7874abac76f45b339/lib/sqlalchemy/sql/ddl.py#L746-L748
|
||||||
create_rule = constraint._create_rule # noqa: SLF001
|
create_rule = constraint._create_rule # noqa: SLF001
|
||||||
add_constraint = AddConstraint(constraint) # type: ignore[no-untyped-call]
|
add_constraint = AddConstraint(constraint)
|
||||||
constraint._create_rule = create_rule # noqa: SLF001
|
constraint._create_rule = create_rule # noqa: SLF001
|
||||||
try:
|
try:
|
||||||
_add_constraint(session_maker, add_constraint, table, column)
|
_add_constraint(session_maker, add_constraint, table, column)
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/integrations/sql",
|
"documentation": "https://www.home-assistant.io/integrations/sql",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"requirements": ["SQLAlchemy==2.0.38", "sqlparse==0.5.0"]
|
"requirements": ["SQLAlchemy==2.0.39", "sqlparse==0.5.0"]
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ PyTurboJPEG==1.7.5
|
|||||||
PyYAML==6.0.2
|
PyYAML==6.0.2
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
securetar==2025.2.1
|
securetar==2025.2.1
|
||||||
SQLAlchemy==2.0.38
|
SQLAlchemy==2.0.39
|
||||||
standard-aifc==3.13.0
|
standard-aifc==3.13.0
|
||||||
standard-telnetlib==3.13.0
|
standard-telnetlib==3.13.0
|
||||||
typing-extensions>=4.12.2,<5.0
|
typing-extensions>=4.12.2,<5.0
|
||||||
|
@ -67,7 +67,7 @@ dependencies = [
|
|||||||
"PyYAML==6.0.2",
|
"PyYAML==6.0.2",
|
||||||
"requests==2.32.3",
|
"requests==2.32.3",
|
||||||
"securetar==2025.2.1",
|
"securetar==2025.2.1",
|
||||||
"SQLAlchemy==2.0.38",
|
"SQLAlchemy==2.0.39",
|
||||||
"standard-aifc==3.13.0",
|
"standard-aifc==3.13.0",
|
||||||
"standard-telnetlib==3.13.0",
|
"standard-telnetlib==3.13.0",
|
||||||
"typing-extensions>=4.12.2,<5.0",
|
"typing-extensions>=4.12.2,<5.0",
|
||||||
|
2
requirements.txt
generated
2
requirements.txt
generated
@ -39,7 +39,7 @@ python-slugify==8.0.4
|
|||||||
PyYAML==6.0.2
|
PyYAML==6.0.2
|
||||||
requests==2.32.3
|
requests==2.32.3
|
||||||
securetar==2025.2.1
|
securetar==2025.2.1
|
||||||
SQLAlchemy==2.0.38
|
SQLAlchemy==2.0.39
|
||||||
standard-aifc==3.13.0
|
standard-aifc==3.13.0
|
||||||
standard-telnetlib==3.13.0
|
standard-telnetlib==3.13.0
|
||||||
typing-extensions>=4.12.2,<5.0
|
typing-extensions>=4.12.2,<5.0
|
||||||
|
2
requirements_all.txt
generated
2
requirements_all.txt
generated
@ -116,7 +116,7 @@ RtmAPI==0.7.2
|
|||||||
|
|
||||||
# homeassistant.components.recorder
|
# homeassistant.components.recorder
|
||||||
# homeassistant.components.sql
|
# homeassistant.components.sql
|
||||||
SQLAlchemy==2.0.38
|
SQLAlchemy==2.0.39
|
||||||
|
|
||||||
# homeassistant.components.tami4
|
# homeassistant.components.tami4
|
||||||
Tami4EdgeAPI==3.0
|
Tami4EdgeAPI==3.0
|
||||||
|
2
requirements_test_all.txt
generated
2
requirements_test_all.txt
generated
@ -110,7 +110,7 @@ RtmAPI==0.7.2
|
|||||||
|
|
||||||
# homeassistant.components.recorder
|
# homeassistant.components.recorder
|
||||||
# homeassistant.components.sql
|
# homeassistant.components.sql
|
||||||
SQLAlchemy==2.0.38
|
SQLAlchemy==2.0.39
|
||||||
|
|
||||||
# homeassistant.components.tami4
|
# homeassistant.components.tami4
|
||||||
Tami4EdgeAPI==3.0
|
Tami4EdgeAPI==3.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user