PhilWaldmann / openrecord

Make ORMs great again!
https://openrecord.js.org
MIT License
486 stars 38 forks source link

Model.create() with Array argument bug #83

Closed arthurfranca closed 5 years ago

arthurfranca commented 5 years ago

Model.create([oneObject]) (array argument) is running beforeSave/beforeValidation twice First time record.isNewRecord equals true. Second one record.isNewRecord equals false

PhilWaldmann commented 5 years ago

Thanks, I'll check that. Should call beforeSave hook only once.

PhilWaldmann commented 5 years ago

Postgres only: beforeSave was called once for the initial create (Multi insert) and a second time for an additional save. In order to mix new records with existing records, the second save call was added to make sure that everything got stored. I've added additional code to ignore the second save for already inserted records.

Thanks

PhilWaldmann commented 5 years ago

Please check v.2.8.3