octabytes / FireO

Google Cloud Firestore modern and simplest convenient ORM package in Python. FireO is specifically designed for the Google's Firestore
https://fireo.octabyte.io
Apache License 2.0
249 stars 29 forks source link

Auto-create nested models for required fields only #192

Closed ADR-007 closed 1 year ago

ADR-007 commented 1 year ago

Problem: models with optional nested fields cannot be saved:

from fireo.fields import NestedModelField, TextField
from fireo.models import Model

class MyNested(Model):
    my_required_field = TextField(required=True)

class MyModel(Model):
    some_field = TextField()
    my_nested = NestedModelField(MyNested, default=None)  # "None" is the default value for default anyway

my_model = MyModel()
my_model.some_field = "some value"
my_model.save()  # error! my_required_field is required