Skip to content
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

batch_op.alter_column fails for server_default=None #361

Closed
sqlalchemy-bot opened this issue Mar 16, 2016 · 3 comments
Closed

batch_op.alter_column fails for server_default=None #361

sqlalchemy-bot opened this issue Mar 16, 2016 · 3 comments
Labels
batch migrations bug Something isn't working

Comments

@sqlalchemy-bot
Copy link

Migrated issue, originally created by Martin Domke (@mdomke)

It is currently not possible to delete an existing server default when using batch_alter_table() by setting the server_default keyword-parameter to None. The migration will fail with an

sqlalchemy.exc.ArgumentError: Argument 'arg' is expected to be one of type '<type 'basestring'>' or '<class 'sqlalchemy.sql.elements.ClauseElement'>' or '<class 'sqlalchemy.sql.elements.TextClause'>', got '<type 'NoneType'>'

I suppose this has been introduced in issue #338. Following the example from that issue, the following doesn't work:

Revision 1:

def upgrade():
    op.create_table(
      'test',
      sa.Column('integer', sa.Integer, nullable=False, primary_key=True),
      sa.Column('string', sa.Text, nullable=False, server_default='default'),
    )

Revision 2:

def upgrade():
    with op.batch_alter_table('test') as batch_op:
        batch_op.alter_column('string', server_default=None)
@sqlalchemy-bot
Copy link
Author

@sqlalchemy-bot
Copy link
Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot
Copy link
Author

Michael Bayer (@zzzeek) wrote:

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batch migrations bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants