New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

drop_column(mssql_drop_check=True) doesn't quote names properly when generating 'drop constraint' SQL #186

Closed
sqlalchemy-bot opened this Issue Mar 12, 2014 · 2 comments

Comments

Projects
None yet
1 participant
@sqlalchemy-bot

sqlalchemy-bot commented Mar 12, 2014

Migrated issue, originally created by Marek Baczyński (@imbaczek)

DB: SQL Server 2008R2

SQLAlchemy==0.9.3

alembic==0.6.4dev

def upgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.add_column('table', sa.Column('col3', sa.Boolean(name='ck_col3'), nullable=True))
    ### end Alembic commands ###


def downgrade():
    ### commands auto generated by Alembic - please adjust! ###
    op.drop_column('table', 'col3', mssql_drop_check=True)
    ### end Alembic commands ###

when downgrading, alembic emits the following SQL

declare @const_name varchar(256)
select @const_name = [name] from sys.check_constraints
where parent_object_id = object_id('table')
and col_name(parent_object_id, parent_column_id) = 'col3'
-- expected
exec('alter table [table] drop constraint [' + @const_name + ']')
-- actually emitted
exec('alter table table drop constraint ' + @const_name)
@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 25, 2014

Michael Bayer (@zzzeek) wrote:

  • Added quoting to the table name when the special EXEC is run to
    drop any existing server defaults or constraints when the
    :paramref:.drop_column.mssql_drop_check or
    :paramref:.drop_column.mssql_drop_default
    arguments are used. fix #186

efecc6c

@sqlalchemy-bot

This comment has been minimized.

sqlalchemy-bot commented Mar 25, 2014

Changes by Michael Bayer (@zzzeek):

  • changed status to closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment