Skip to content

Conversation

zjwhitehead
Copy link

Currently when adding a date field to a template and calling a document that doesnt yet have that date filled out the SDK raises an error because it cant convert an empty string or nil to a Date/Time.
It will still raise an error for malformed dates.

This fixes it by returning an empty text fragment (so calling .value) still works.

I thought about a few other approaches but this seems to have the lowest impact. Open to feedback

@zjwhitehead
Copy link
Author

Btw looks like these same tests that failed are failing in master

@zjwhitehead
Copy link
Author

What are your thoughts on this @faresd ?

@faresd
Copy link
Contributor

faresd commented Oct 6, 2021

@alistairholt can you help here?

@alistairholt
Copy link
Collaborator

@faresd sure. I'll take a look.

@alistairholt alistairholt self-assigned this Oct 6, 2021
@alistairholt
Copy link
Collaborator

@zjwhitehead thanks for your contribution and apologies for the massive delay in responding. While it works it feels slightly icky that we would return a Prismic::Fragments::Text instance when we are expecting a Prismic::Fragments::Date instance. I think it would be better if we adjust Prismic::Fragments::Date#to_html to simply do an early return with an empty string ('') if the value is nil.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants