-
-
Notifications
You must be signed in to change notification settings - Fork 229
Fix nullable date/datetime properties #267
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,6 +1,11 @@ | ||||||||||
{% macro construct(property, source, initial_value="None") %} | ||||||||||
{% if property.required %} | ||||||||||
{% if property.nullable %} | ||||||||||
{{ property.python_name }} = {{ source }} | ||||||||||
{{ property.python_name }} = isoparse({{ property.python_name }}).date() if {{ property.python_name }} else None | ||||||||||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes as they are here would cause type issues, I think, because the type of You would need to put the
Suggested change
But I think @dbanty's suggestion would work and would be a bit simpler. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, I will try to fix that today! |
||||||||||
{% else %} | ||||||||||
{{ property.python_name }} = isoparse({{ source }}).date() | ||||||||||
{% endif %} | ||||||||||
{% else %} | ||||||||||
{{ property.python_name }} = {{ initial_value }} | ||||||||||
_{{ property.python_name }} = {{ source }} | ||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
{% macro construct(property, source, initial_value="None") %} | ||
{% if property.required %} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same thing here I think |
||
{% if property.nullable %} | ||
{{ property.python_name }} = {{ source }} | ||
{{ property.python_name }} = isoparse({{ property.python_name }}) if {{ property.python_name }} else None | ||
{% else %} | ||
{{ property.python_name }} = isoparse({{ source }}) | ||
{% endif %} | ||
{% else %} | ||
{{ property.python_name }} = {{ initial_value }} | ||
_{{ property.python_name }} = {{ source }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead, couldn't we do this:
and let the below else handle None?