emmett-framework / emmett

The web framework for inventors
BSD 3-Clause "New" or "Revised" License
1.06k stars 71 forks source link

Prevent this error in model definition #316

Closed josejachuf closed 3 years ago

josejachuf commented 3 years ago

The following happened to me, I defined by mistake a string field in this way:

my_field = Field.string(length='1') # length is a string

In migration the table was created correctly and did not skip any error or warning. But when I wanted to insert a record, I threw the error. Look for the solution on the side of the model, but I could not find anything, until I realized my mistake.

less = value <= self.maxsize

TypeError: '<=' not supported between instances of 'int' and 'str'

While the error was mine, not jumping when migrating the model, it was quite difficult to find it later

Best regards Jose