Conflicting Columns

When inserting data, conflicting columns may arise due to database constraints, such as unique keys or primary keys. QueryDeck provides mechanisms to handle such conflicts gracefully using the on_conflict clause. This ensures that duplicate records do not cause the operation to fail and allows you to define specific actions when conflicts occur.

Implementation

Choose the button with your table name (here, customers). This is used to manipulate column display

In the pop up that opens, choose conflicting columns

Now choose a constraint of your choice

Then select columns you want to include

Then click on save, to write the changes

Testing

Copy the URL endpoint from the top right corner

Now open postman and paste the link in the URL input bar, and change the method to POST

Under the "body" tab, click on "raw" and then use a request body. Here's an example body

{
  "customer": [
    {
      "email": "[email protected]",
      "active": 1,
      "store_id": 1,
      "last_name": "Doe",
      "activebool": true,
      "address_id": 1,
      "first_name": "John",
      "create_date": "2023-01-01",
      "last_update": "2023-01-01T12:00:00.000Z"
    }
  ],
  "on_conflict": {
    "constraint": "customers_email_key",
    "update_columns": ["last_name", "active", "last_update"]
  }
}

Hit send to place the request

Here is an example response of what we should get

Last updated