Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some form of support for nullable fields #10

Open
yrd opened this issue Sep 19, 2022 · 0 comments
Open

Add some form of support for nullable fields #10

yrd opened this issue Sep 19, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@yrd
Copy link
Member

yrd commented Sep 19, 2022

Currently, an upstream null resolves into this error:

if raw_value is None:
raise AttributeError(
f"Trying to access an undefined field {self.name!r} in record "
f"{type(record)!r}. Either add the field to the module "
f"definition or check for the correct spelling."
)

The first idea would be to add an argument when building the field:

optional_string = model.StringField(optional=True)

Or use a wrapper:

optional_integer = model.OptionalField(model.IntegerField())
@yrd yrd added the enhancement New feature or request label Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant