vapor-community / mongo-driver

MongoDB driver for Fluent
28 stars 26 forks source link

[FIX] (makeDocument) Saving arrays on fluent models failing #36

Closed plummer closed 7 years ago

plummer commented 7 years ago

Hi,

I'm unable to save arrays in fluent models with Mongo. I don't know if this is the most appropriate way or place to fix this, however it works.

My failing code inside makeRow is: try row.set("list", list) where list is Node made with Node.array([Node]).

Currently saves a blank object, not actually an array, and with no data.

Change: Checks if it is an array, and converts to document. Saving now successful.

plummer commented 7 years ago

Note, softDelete test failing before PR.

Joannis commented 7 years ago

If you could add a test with a model containing an array, that'd make this perfect!

plummer commented 7 years ago

Will do, thanks!

plummer commented 7 years ago

Hey @Joannis, wasn't really sure where to put tests, given AFAIK this functionality is only for Mongo and the rest of the tests are reused from Fluent. However these tests fail without the above PR, and pass now.

Let me know at a high level if / how you want me to change the tests - thanks!

Joannis commented 7 years ago

I'm having a look tonight

valeriomazzeo commented 7 years ago

having the same issue, I can confirm this PR fixes it