Files
supabase/apps/studio/components/interfaces/TableGridEditor
Aaditya BhusalandAli Waseem bbe5afff61 fix: omit cleared default fields on row insert (#46826)
## I have read the
[CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md)
file.

YES

## What kind of change does this PR introduce?

Bug fix

## What is the current behavior?

Closes #46824 

In the Studio table editor, when inserting a new row into a table with
an auto-generated primary key (or any non-text column with a default
value), clearing the field after editing it sends an empty string `""`
in the insert payload. This causes Postgres to reject the insert with:

```txt
ERROR: 22P02: invalid input syntax for type bigint: ""
```

## What is the new behavior?

When inserting a new row, cleared fields that are
identity/default-backed and non-text are now omitted from the insert
payload, so Postgres applies the column default or identity generation
instead of receiving an empty string.

For example:
- id bigint generated by default as identity cleared → omitted, Postgres
auto-generates id.
- created_at timestamptz default now() cleared → omitted, Postgres
applies now().
- name text cleared → preserved as "", because empty string is a valid
explicit text value.

## Additional context

After the fix:


https://github.com/user-attachments/assets/78e9eb9c-9518-4894-8547-d18ffa78869a


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* New-record saving now respects column defaults and identity behavior:
empty inputs for identity or defaulted non-text columns are omitted so
defaults are applied, while intentional empty strings for text fields
are preserved.

* **Tests**
* Added test coverage validating new-row creation behavior with
default/identity handling and empty-text preservation.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Ali Waseem <waseema393@gmail.com>
2026-06-11 08:41:43 -06:00
..