Skip to content

fix(postgrest): send no columns parameter when bulk rows have no keys - #2209

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-3079-empty-columns
Nov 30, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-3079-empty-columns

Conversation

@spydon

@spydon spydon commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

`insert([{}])` and `upsert([{}])` sent `?columns=`, which PostgREST rejects. Fixes SDK-3079.

  • Skip the `columns` parameter when the union of row keys is empty, matching js, swift, kotlin and py.
  • Tests for both `insert` and `upsert`.

Summary by CodeRabbit

  • Bug Fixes

    • Insert and upsert requests with rows containing no fields now omit the columns query parameter, while preserving the empty row in the request body.
  • Tests

    • Added coverage for empty-field rows in insert and upsert requests.

@github-actions github-actions Bot added the postgrest This issue or pull request is related to postgrest label Nov 30, 2026
@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The query builder now omits the columns parameter when rows contain no keys. Tests cover this behavior for insert() and upsert() with an empty row.

Changes: Empty-row handling

Layer / File(s) Summary
Column parameter and coverage
packages/postgrest/lib/src/postgrest_query_builder.dart, packages/postgrest/test/insert_builder_test.dart
The query builder omits the columns parameter when the collected row keys are empty. Tests verify that insert() and upsert() send [{}] without a columns parameter.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix

Suggested labels: postgrest

Suggested reviewers: androidpoet

Merge Risk: Minimal · up to ce77f

This change stops insert and upsert with empty rows from sending an empty columns parameter, and tests cover both. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the change: bulk inserts or upserts whose rows have no keys no longer send a columns parameter. The raw summary confirms _setColumnsSearchParam now returns the base URL when the unio…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the change: bulk inserts or upserts whose rows have no keys no longer send a columns parameter. The raw summary confirms _setColumnsSearchParam now returns the base URL when the union of row keys is empty, and the objectives describe the fix for SDK-3079 where insert([{}]) and upsert([{}]) sent ?columns=. The title is specific and matches the main change.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 6edcce8 and ce77f58.

Files selected for processing: 2

  • packages/postgrest/lib/src/postgrest_query_builder.dart
  • packages/postgrest/test/insert_builder_test.dart

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 1 remain after this review.

@spydon
spydon merged commit 7120bfb into main Nov 30, 2026
61 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-3079-empty-columns branch November 30, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

postgrest This issue or pull request is related to postgrest

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant