mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Improve some comments in recorder migration code (#123969)
This commit is contained in:
parent
629b919707
commit
72e235ad9f
@ -607,7 +607,7 @@ def _update_states_table_with_foreign_key_options(
|
|||||||
"columns": foreign_key["constrained_columns"],
|
"columns": foreign_key["constrained_columns"],
|
||||||
}
|
}
|
||||||
for foreign_key in inspector.get_foreign_keys(TABLE_STATES)
|
for foreign_key in inspector.get_foreign_keys(TABLE_STATES)
|
||||||
if foreign_key["name"]
|
if foreign_key["name"] # It's not possible to drop an unnamed constraint
|
||||||
and (
|
and (
|
||||||
# MySQL/MariaDB will have empty options
|
# MySQL/MariaDB will have empty options
|
||||||
not foreign_key.get("options")
|
not foreign_key.get("options")
|
||||||
@ -663,7 +663,7 @@ def _drop_foreign_key_constraints(
|
|||||||
if foreign_key["name"] and foreign_key["constrained_columns"] == [column]
|
if foreign_key["name"] and foreign_key["constrained_columns"] == [column]
|
||||||
]
|
]
|
||||||
|
|
||||||
## Bind the ForeignKeyConstraints to the table
|
## Find matching named constraints and bind the ForeignKeyConstraints to the table
|
||||||
tmp_table = Table(table, MetaData())
|
tmp_table = Table(table, MetaData())
|
||||||
drops = [
|
drops = [
|
||||||
ForeignKeyConstraint((), (), name=foreign_key["name"], table=tmp_table)
|
ForeignKeyConstraint((), (), name=foreign_key["name"], table=tmp_table)
|
||||||
@ -829,9 +829,9 @@ def _delete_foreign_key_violations(
|
|||||||
result = session.connection().execute(
|
result = session.connection().execute(
|
||||||
# We don't use an alias for the table we're deleting from,
|
# We don't use an alias for the table we're deleting from,
|
||||||
# support of the form `DELETE FROM table AS t1` was added in
|
# support of the form `DELETE FROM table AS t1` was added in
|
||||||
# MariaDB 11.6 and is not supported by MySQL. Those engines
|
# MariaDB 11.6 and is not supported by MySQL. MySQL and older
|
||||||
# instead support the from `DELETE t1 from table AS t1` which
|
# MariaDB instead support the from `DELETE t1 from table AS t1`
|
||||||
# is not supported by PostgreSQL and undocumented for MariaDB.
|
# which is undocumented for MariaDB.
|
||||||
text(
|
text(
|
||||||
f"DELETE FROM {table} " # noqa: S608
|
f"DELETE FROM {table} " # noqa: S608
|
||||||
"WHERE ("
|
"WHERE ("
|
||||||
|
Loading…
x
Reference in New Issue
Block a user