vogels
vogels copied to clipboard
Date field in nested object inside array is not saved
I noticed a strange issue with this sort of data schema:
schema: {
id: Joi.string(),
content: {
payments: {
manual_entries: Joi.array().items({
id: Joi.string().allow(null),
date: Joi.date(),
}),
},
},
}
When I save a new row in the table using that structure and read it back again, the date field is missing. However if I insert the same data without using Vogels, it works fine. Similarly, if I change the Date object to a string, it will also work fine.
Here is a gist that you can run to reproduce the issue
I'm guessing it's an issue with the serializer?
Did you find a solution to this ?
I haven't found a proper resolution yet, though for now I've gone with the workaround of changing Joi.Date to Joi.String for the field as I've already validated the date elsewhere in my application
I think it might be because of that issue https://github.com/ryanfitz/vogels/issues/156
I ended up finding a resolution which is to use vogels.types.stringSet()
for arrays. I think if you look into the definition of stringSet()
it is just using array but has some metadata on it.
@RodH257 You should try different syntax for the declaration of your schema. Please take a look at this example here.
Joi.string().isoDate()
Not sure if anyone responded with this via link but the above seems to solve it.
Also seeing this issue. For the time being using strings to store ISO formatted dates.