Skip to content

Migration tries to set callable object repr as column default in SQL, fails #147

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

Closed
artem30801 opened this issue Apr 3, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@artem30801
Copy link

artem30801 commented Apr 3, 2021

I made a custom object with call method and pass it like:

role_number = NextNumber()

class Role(Model):
    id = fields.IntField(pk=True)
    number = fields.IntField(default=role_number)

When I called "aerich migrate" it gives following error:
AttributeError: 'NextNumber' object has no attribute 'name'

When I impelemnt name attribute for the object, it generates following SQL code in file in /migrate folder (among other lines)
ALTER TABLE role MODIFY COLUMN number INT NOT NULL COMMENT 'Priority (ordering) of the role' DEFAULT '<function cogs.db_utils.NextNumber:<class 'cogs.roles.Role'>:number>';
Obviously this leads to faililure of executing aerich upgrade command

@long2ice
Copy link
Member

long2ice commented Apr 4, 2021

Yes, which should be ignore

@long2ice long2ice added the bug Something isn't working label Apr 4, 2021
@long2ice
Copy link
Member

long2ice commented Apr 5, 2021

Fixed

@long2ice long2ice closed this as completed Apr 5, 2021
@artem30801
Copy link
Author

Thank you!

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

No branches or pull requests

2 participants