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

sqlalchemy.exc.CompileError with MYSQL->MYSQL migrate #31

Open
buctwang opened this issue Mar 5, 2018 · 0 comments
Open

sqlalchemy.exc.CompileError with MYSQL->MYSQL migrate #31

buctwang opened this issue Mar 5, 2018 · 0 comments

Comments

@buctwang
Copy link

buctwang commented Mar 5, 2018

Hi,

My source mysql database 'test' has one table and it has two columns:

    id int(11)
    context   longtext

when I migrate it to another database, The type of 'longtext' cause one exception:
sqlalchemy.exc.CompileError: (in table 'new_table', column 'context'): VARCHAR requires a length on dialect mysql

I debug the sqlalchemy source and find the function called is visit_VARCHAR:

def visit_LONGTEXT(self, type_, **kw):
    return self._extend_string(type_, {}, "LONGTEXT")

def visit_VARCHAR(self, type_, **kw):
   if type_.length:
       return self._extend_string(
           type_, {}, "VARCHAR(%d)" % type_.length)
   else:
       raise exc.CompileError(
           "VARCHAR requires a length on dialect %s" %
           self.dialect.name)

I don't understand all _StringType type call this funtion visit_VARCHAR, not vistit_LONGTEXT? And how to deal with longtext type? Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant