Skip to content

Expected behavior with defaultToNull set to true in bulk inserts #1651

@devpulse01

Description

@devpulse01

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When performing bulk inserts using the Supabase JS client with the defaultToNull option,
the behavior of handling missing columns seems to vary based on the presence of the
column in other rows within the same payload.

To Reproduce

Payload with mixed presence of "name" column:

const payload = [
  { category_id: 'a9278bf3' },
  { name: 'MyTask', category_id: 'a9278bf3' }
];

With defaultToNull: true: the first row has the "name" set to null as expected.


Payload with consistently missing "name" Column:

const payload = [
  { category_id: 'a9278bf3' },
  { category_id: 'a9278bf3' }
];

With defaultToNull: true: both rows use the column's default value for the "name" column and not null.

Expected behavior

Is this behavior expected when using the defaultToNull option in bulk inserts?

Specifically, should missing columns be inserted as null only if at least one row in the payload specifies the column?

System information

  • Version of supabase-js: 2.43.4

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpostgrest-jsRelated to the postgrest-js library.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions