Hi, thanks for creating this great library, it's just what I was looking for, simple but powerful.
I think I found a bug though. On a TextField, setting max_length when required is False results in the error "TypeError: 'NoneType' object is not subscriptable". Here's an example, notice that the locality is not specified in the address dictionary.
class Address(Model):
premises = TextField(required=True, max_length=256)
thoroughfare = TextField(required=True, max_length=256)
locality = TextField(max_length=256)
city = TextField(max_length=256, required=True)
postcode = TextField(required=True, max_length=8, format='upper',
to_lowercase=True, validator=validate_postcode)
address = {
"premises": "Flat 8, 189",
"thoroughfare": "Furlington Road",
"city": "Leeds",
"postcode": "LS23 3HJ"
}
a = Address.from_dict(address)
a.save()
print(a.to_dict())
File "/app/app.py", line 59, in <module>
c.save()
File "/usr/local/lib/python3.8/site-packages/fireo/models/model.py", line 342, in save
return self.__class__.collection.create(self, transaction, batch, **self._get_fields())
File "/usr/local/lib/python3.8/site-packages/fireo/managers/managers.py", line 189, in create
return self.queryset.create(mutable_instance, transaction, batch, **field_list)
File "/usr/local/lib/python3.8/site-packages/fireo/queries/query_set.py", line 52, in create
return CreateQuery(self.model_cls, mutable_instance, **kwargs).exec(transaction_or_batch)
File "/usr/local/lib/python3.8/site-packages/fireo/queries/create_query.py", line 130, in exec
return query_wrapper.ModelWrapper.from_query_result(self.model, self._raw_exec())
File "/usr/local/lib/python3.8/site-packages/fireo/queries/create_query.py", line 123, in _raw_exec
ref.set(self._parse_field())
File "/usr/local/lib/python3.8/site-packages/fireo/queries/create_query.py", line 93, in _parse_field
self._nested_field_list(f, field_list, f.name)
File "/usr/local/lib/python3.8/site-packages/fireo/queries/create_query.py", line 111, in _nested_field_list
nested_field_list[n_f.db_column_name] = n_f.get_value(
File "/usr/local/lib/python3.8/site-packages/fireo/fields/base_field.py", line 121, in get_value
val = self.field_attribute.parse(val, ignore_required, ignore_default)
File "/usr/local/lib/python3.8/site-packages/fireo/fields/field_attribute.py", line 111, in parse
value = self.call_attr_method(attr, value)
File "/usr/local/lib/python3.8/site-packages/fireo/fields/field_attribute.py", line 176, in call_attr_method
return getattr(self.field, "attr_"+attr)(self.field_attr(attr), value)
File "/usr/local/lib/python3.8/site-packages/fireo/fields/text_field.py", line 34, in attr_max_length
return field_val[:attr_val]
TypeError: 'NoneType' object is not subscriptable```