vogels icon indicating copy to clipboard operation
vogels copied to clipboard

Date field in nested object inside array is not saved

Open RodH257 opened this issue 8 years ago • 7 comments

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?

RodH257 avatar Apr 10 '16 10:04 RodH257

Did you find a solution to this ?

justinmchase avatar Apr 26 '16 21:04 justinmchase

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

RodH257 avatar Apr 27 '16 02:04 RodH257

I think it might be because of that issue https://github.com/ryanfitz/vogels/issues/156

sylwit avatar May 27 '16 19:05 sylwit

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.

justinmchase avatar May 27 '16 19:05 justinmchase

@RodH257 You should try different syntax for the declaration of your schema. Please take a look at this example here.

set-killer avatar May 27 '16 20:05 set-killer

Joi.string().isoDate()

Not sure if anyone responded with this via link but the above seems to solve it.

kristajg avatar Jul 20 '16 18:07 kristajg

Also seeing this issue. For the time being using strings to store ISO formatted dates.

ldadams avatar Oct 19 '16 14:10 ldadams