-
Notifications
You must be signed in to change notification settings - Fork 643
Closed
Labels
Description
upsertGraph uses insertGraph and expects it to do the job, but insertGraph cannot relate a HasManyRelation because it is an update operation, not an insert. insertGraph only inserts stuff.
insertGraph should throw an exception in this case and advice the user to use upsertGraph instead. upsertGraph should just work.
Thank you @Allam76 for bringing this to our attention!
Reproduction provided by @Allam76
const {up, down} = require('./migrations/20150613161239_initial_schema');
async function test(){
await up(knex);
var person = await Person.query().insert({id:1,firstName:"Peter",lastName:"Jackson"});
var pet = await Animal.query().insert({id:1, name:"Mila"});
var test = await Person.query().upsertGraph({
id:1,
pets:[{
id:1
}]
},{relate:true}).debug();
}
test();