converting a column from varchar to int does not work on postgresql

Issue #2457 resolved
Former user created an issue

When converting a column from varchar to integer using postgresql sqlalchemy (version 0.7.5) lacks a postgres specific statement for the proper conversion.

It creates e.g.: ALTER TABLE images ALTER COLUMN id TYPE INTEGER; But it should be e.g.: ALTER TABLE images ALTER COLUMN id TYPE INTEGER using id::integer;

Comments (3)

  1. Mike Bayer repo owner

    The "using" keyword which this ticket refers to is specific to something we'll be doing in alembic.

    As for the openstack bug, it looks like a runtime data coercion issue that was local to their application. It doesn't appear related to the alembic issue here, which refers to ALTER TABLE mechanics, not runtime data mechanics. They appear to have resolved the issue locally by coercing their data before passing along to the statement.

    SQLAlchemy doesn't do data coercion automatically - if you need to transparently coerce ints to varchars, use a type decorator: http://docs.sqlalchemy.org/en/rel_0_7/core/types.html#typedecorator-recipes.

    I don't see any details here related to SQLAlchemy-migrate so I cannot take any action on that without specifics.

    If there is a specific SQLAlchemy bug here that can be identified as unexpected results in SQLAlchemy, then that can be posted here per the ticket guidelines at http://www.sqlalchemy.org/participate.html#bugs, the most important aspect being a simple demonstration of the bug which anyone can run on their own workstation. But as it stands I see no action to be taken here - please open a new ticket once you can make specifics available - thanks !

  2. Log in to comment