Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manyOf relationship in nullable objects #288

Open
diogomiguel opened this issue Oct 11, 2023 · 1 comment
Open

manyOf relationship in nullable objects #288

diogomiguel opened this issue Oct 11, 2023 · 1 comment

Comments

@diogomiguel
Copy link

diogomiguel commented Oct 11, 2023

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

@yishay-at-bay
Copy link

Hey @diogomiguel
Only saw now that my PR was merged
I will try to take a look at the issue you raised here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants