Skip to content

Inserting graph with an empty relation no longer works. #1227

@mastermatt

Description

@mastermatt

I'm not positive if this a bug/regression or if I've been doing it wrong and need guidance on what the "right way" is. But I do have code that breaks when I attempt to upgrade to at least 1.5.0 where 46d9370 as added.

Simplified example:

await Person.query().upsertGraph({
  firstName: 'Jennifer',
  lastName: 'Aniston',
  parent: {}, // BelongsToOneRelation
});

In my case I'm dealing with a one-to-one for polymorphic attributes, but that shouldn't matter here.
What use to happen was two INSERTs would fire off, one for the primary object and one for the relationship. For the second, it would only insert the ID of the new primary object (plus any defaults).
However, as of 1.5, only the first INSERT is executed.

Regression or is there a better way to insert an "empty" relation in a graph?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions