From: Mike Bayer Date: Mon, 25 Nov 2024 18:57:58 +0000 (-0500) Subject: support separation of Numeric/Float X-Git-Tag: rel_1_14_1~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3815c571b606b37ecbded32a613f2615db9b5d5c;p=thirdparty%2Fsqlalchemy%2Falembic.git support separation of Numeric/Float in [1] we are considering separating Numeric and Float. For Alembic PostgreSQL backend we need this isinstance therefore to check for both Numeric and Float. By keeping it to these two types, rather than targeting the NumericCommon type being added in [1], the patch can work with SQLAlchemy without the separation change as well. [1] https://gerrit.sqlalchemy.org/c/sqlalchemy/sqlalchemy/+/3587 Change-Id: I0c956ba8797e38a62ea630ab65cd53779bbf1972 --- diff --git a/alembic/ddl/postgresql.py b/alembic/ddl/postgresql.py index de64a4e0..60aa1536 100644 --- a/alembic/ddl/postgresql.py +++ b/alembic/ddl/postgresql.py @@ -16,6 +16,7 @@ from typing import TYPE_CHECKING from typing import Union from sqlalchemy import Column +from sqlalchemy import Float from sqlalchemy import literal_column from sqlalchemy import Numeric from sqlalchemy import text @@ -132,7 +133,7 @@ class PostgresqlImpl(DefaultImpl): metadata_default = metadata_column.server_default.arg if isinstance(metadata_default, str): - if not isinstance(inspector_column.type, Numeric): + if not isinstance(inspector_column.type, (Numeric, Float)): metadata_default = re.sub(r"^'|'$", "", metadata_default) metadata_default = f"'{metadata_default}'"