question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error 'All object keys must match'

See original GitHub issue

Bug report

Describe the bug

When trying to insert an array of objects, where in some objects the key field2 is present, and in others isn’t, the JS API client errors to: ‘All object keys must match’. The field2 is not mandatory.

const { data, error } = await supabase
  .from('mytable')
  .insert([
    {
      field1: 'something'     
    },
    {
      field1: 'something',
      field2: 'something'        
    }      
])

Desired behavior

The JS client / Supabase should default the mismatching fields to null or whatever is translated to NULL in Postgres. (As workaround I set the fields to null and it looks OK in my case.)

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:13
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

22reactions
travisandersoncommented, Apr 15, 2022

+1 for this. I mean, I thought that is what upsert is for.

I have multiple rows…if I add a new one, it doesn’t have an ID yet…so, I would expect existing items get updated, while the new one, gets inserted.

16reactions
Polyterativecommented, Apr 22, 2021

I would like to know about this myself since I’m trying to upsert.

In my situation I can have references to the ids of the rows but in the same operation I also need to add new rows of which I do not have an identifier.

image

This returns {"message":"All object keys must match"}

summing up the upsert does not do what I expect that is to add new rows and update those already in db in the same operation.

this forces me to have to make two separate api calls for insert and update

Read more comments on GitHub >

github_iconTop Results From Across the Web

Random problems trying to create a row in Supabase
The error message I get is " ERROR: Bad request - please check your parameters. All object keys must match". All values are...
Read more >
How to type-enforce object value to match object key?
We want to be able to just look at an object and see if its keys match its category strings. We can do...
Read more >
Object.keys() - JavaScript - MDN Web Docs
The Object.keys() method returns an array of a given object's own enumerable string-keyed property names.
Read more >
Objects - The Modern JavaScript Tutorial
So we must understand them first before going in-depth anywhere else. An object ... Every piece of data is stored in its file...
Read more >
Creating object key names - Amazon Simple Storage Service
To ensure the correct parsing of object keys in XML requests, carriage returns and other special characters must be replaced with their equivalent...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found