manyOf relationship in nullable objects
diogomiguel opened this issue · comments
With the feature introduced by #257, setting a nullable object to null that has a nested relationship (tested with ManyOf
), results in a TypeError: Object.defineProperty called on non-object
E.g:
const db = factory({
a: {
id: primaryKey(() => 1),
nested: nullable({
b: manyOf('b') // problematic
})
},
b: {
id: primaryKey(() => 1)
}
});
// Works fine
db.a.create()
// Works fine
db.a.create({ nested: { b: [db.b.create()] } })
// Error
db.a.create({ nested: null })
Object.defineProperty
in definePropertyAtPath is called with null
(parent
)
CC @yishayweb