Objection.js: Graph upsert doesn't work if root model doesn't have an id

Created on 2 Sep 2017  路  2Comments  路  Source: Vincit/objection.js

Trying to use upsertGraph() as described in documentation.

By default upsertGraph method updates the objects that have an id, inserts objects that don鈥檛 have an id and deletes all objects that are not present.

When calling upsertGraph() with no id

Season.query().upsertGraph({
    title: 'Title',
    episodes: [{
        title: 'Episode'
    }]
})

I expect objection to insert a season object with a single episode. Instead, I am getting

Error: undefined passed as an item in argument #1 for 'whereInComposite' operation. Call skipUndefined() method to ignore the undefined values.

However everything starts working after I add id to the season. But then upsertGraph does not insert a new season, but only updates existing one. Is this the expected behaviour of upsertGraph? Can objection also insert season when season is provided without id?

p.s. Thanks for great tool!

bug

Most helpful comment

@beworker This should be fixed in 0.8.9. Please let me know if your problems remain.

All 2 comments

Thanks for filling out this report. There seems to be a bug that prevents the root objects from being inserted. I'll fix this for the next release.

@beworker This should be fixed in 0.8.9. Please let me know if your problems remain.

Was this page helpful?
0 / 5 - 0 ratings