Closed wspek closed 5 years ago
This is why we have stuff like "column_name":
class MyModel(Model):
insert_ = TextField(column_name='insert')
@coleifer
I have made sure all my columns are explicitly named now by using your suggestion. I hope this GIF demonstrates well that even though the insert column has an explicit column_name
set, the self.insert
class method is still assuming the value of the field.
Sorry, I think I get your point. I have to pay attention to the underscore you wrote down.
Version: 3.9.6
I have discovered that when I create a Model which has a column literally named insert, the peewee code will throw an exception when trying to insert data through the
Model.insert
class method in line 6311:pk = self.insert(**field_dict).execute()
To reproduce simply create a model which has a column named insert. In my case, after adding a Model with the column named insert, things look like this:
Note the type
None
of the insert class method, which is due to the fact that now a column exists in the model with valueNone
. After the actual field data is added, in my case, the insert field has valueFalse
. Because the code then tries to callexecute()
on this boolean value, ultimately my code fails with an exception:ERROR 'bool' object is not callable
My Model also has columns delete and create, which may cause problems by overwriting class methods with the same names. That is because I am storing a table which contains database permissions for an unrelated software solution.
Thanks.