Description
Migrated issue, originally created by Dimitrios Theodorou (@dtheodor)
After updating Alembic from 0.6.2 to the latest I am getting an exception in the PostgresqlIpml.compare_server_default
. In particular:
My DB schema:
CREATE TABLE stuff (
value1 float DEFAULT 0
)
My SQL Alchemy model:
class Stuff(Base):
value1 = Column(Float, server_default="0.0")
The compare_server_default emits this SQL query (on the left is the rendered_inspector_default, on the right the rendered_metadata_default):
SELECT 0 = '0.0';
which fails with the DataError ERROR: invalid input syntax for integer: "0.0"
In Postgres, the DEFAULT values 0
, 0.0
and '0.0
' are all valid and have identical end-result for a float column.
What would the "proper" solution be here, catch the exception and return False in the comparison, or check the column type and cast to float before comparing?
To avoid the error I set the server_default
to a float value (server_default=text("0.0")
)