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

Primary key changing on Upsert #342

@GollyJer

Description

@GollyJer

Hi. I've discussed this in discord with tanmaig aka @coco98.

I have the following table structure.
2018-08-31_14h03_41

A tweet can contain many symbols and a symbol can be in many tweets. Classic many to many relationship.

The problem. If I try to upsert anything to an existing row in the symbol table graphql wants to change the primary key which will break the relationship to tweets.

  mutation upsert_symbol {
    insert_symbol(
      objects: [{ symbol: "INTC", is_stock: true, is_crypto: false }]
      on_conflict: { constraint: symbol_symbol_key, action: update }
    ) {
    returning {
      id
      symbol
    }
      affected_rows
    }
  }

In this case, if INTC already exists and is_crypto is being changed then the row is deleted and recreated with a new primary key. 😳

The same thing happens even if [{ symbol: "INTC", is_stock: true, is_crypto: false }] already have the same values.

@coco98 and @0x777 have discussed and plan on releasing a fix shortly.
2018-08-31_14h14_10
2018-08-31_14h17_44

They asked me to make this issue so they have something to attach to the PR.

Thanks!
Jeremy

Metadata

Metadata

Assignees

Labels

c/serverRelated to serverk/bugSomething isn't workingp/urgentImmediate action required

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions