You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a migration script that first adds a column and then initializes it. I am using MySQL. However, after adding the column, the model's ForeignKeyField is changed in a way that results in a recursion error by simply selecting or updating the new field:
RecursionError: maximum recursion depth exceeded
To reproduce it, imagine we have the two tables below, and I want to add a ForeignKeyField column to the Rice table:
frompeeweeimportModel, ForeignKeyField, TextFieldclassBean(Model):
name=TextField(default="Red")
classMeta:
database=dbclassRice(Model):
name=TextField(default="Brown")
bean=ForeignKeyField(Bean, null=True, backref='rices') # <-- we want to add this fieldclassMeta:
database=db
Now, let's say I migrate the Rice table with something like this:
I have a migration script that first adds a column and then initializes it. I am using MySQL. However, after adding the column, the model's
ForeignKeyField
is changed in a way that results in a recursion error by simply selecting or updating the new field:To reproduce it, imagine we have the two tables below, and I want to add a
ForeignKeyField
column to theRice
table:Now, let's say I migrate the
Rice
table with something like this:As a result of this line:
peewee/playhouse/migrate.py
Line 237 in 7eb7498
Rice.bean.name
, gets changed from"bean"
to"bean_id"
. This causes aRecursionError
the next time we select that field.The text was updated successfully, but these errors were encountered: