这是indexloc提供的服务,不要输入任何密码
Skip to content

One to One relationship causing Not-Null Constraint Violation on Nested Data Insert #2576

@emahuni

Description

@emahuni
{
  "errors": [
    {
      "extensions": {
        "path": "$.selectionSet.insert_a.args.objects[0]",
        "code": "constraint-violation"
      },
      "message": "Not-NULL violation. null value in column \"id\" violates not-null constraint"
    }
  ]
}

The following table definitions reproduce the above error:

Tables

Table a:

Screenshot 2019-07-20 at 14 58 23

Table B:

Screenshot 2019-07-20 at 14 58 42

Relationships

Table A:

Screenshot 2019-07-20 at 14 59 54

Table B:

Screenshot 2019-07-20 at 15 00 10

Invoking The Error

That error happens when inserting data from the "has one" side (table a), but not when inserting from the "belongs to" side (I wish Hasura could label relationships like this as well in addition to what's there to make things clear quickly):

the above error happens when you run this query:

mutation {
  insert_a(objects: {
    junk_a: "This is a's junk"
    b:{
      data: 
        {
          junk_b: "B's junk inserted when inserting a's junk"
        }
    }
  }){
    affected_rows
  }
}

but not when you run this query from the other side:

mutation {
  insert_b(objects: {
    junk_b: "This is B's junk"
    a:{
      data: 
        {
          junk_a: "A's junk inserted when inserting B's junk"
        }
    }
  }){
    affected_rows
  }
}

This could be related to #2508, but I am not sure cause what he is reporting on is different.

Metadata

Metadata

Assignees

Labels

c/serverRelated to serverk/bugSomething isn't workingp/highcandidate for being included in the upcoming sprint

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions