From 3815c571b606b37ecbded32a613f2615db9b5d5c Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Mon, 25 Nov 2024 13:57:58 -0500 Subject: [PATCH] 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 --- alembic/ddl/postgresql.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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}'" -- 2.47.3