]> git.ipfire.org Git - thirdparty/sqlalchemy/alembic.git/commitdiff
support separation of Numeric/Float
authorMike Bayer <mike_mp@zzzcomputing.com>
Mon, 25 Nov 2024 18:57:58 +0000 (13:57 -0500)
committerMike Bayer <mike_mp@zzzcomputing.com>
Mon, 25 Nov 2024 18:57:58 +0000 (13:57 -0500)
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

index de64a4e05b5b2252d77f14a33380ac626a5c6c54..60aa15366c2db1c71f24602f38202c914caa5ffe 100644 (file)
@@ -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}'"