Skip to content

fix(postgrest): omit the columns parameter when a bulk insert has no keys - #2048

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2763-empty-bulk-insert-columns
Nov 13, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2763-empty-bulk-insert-columns

Conversation

@spydon

@spydon spydon commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

insert([]), upsert([]) and bulk payloads whose rows have no keys ([{}]) sent ?columns= with an empty value, because pre_insert and pre_upsert always set the parameter for list bodies.

Both now only add columns when the rows contribute at least one key. Upsert keeps its on_conflict parameter either way.

Tests

Added test_bulk_insert_without_columns and test_bulk_upsert_without_columns to the async and sync request builder tests, parametrized over [] and [{}]. Both fail without the fix.

Closes SDK-2763

@coderabbitai

coderabbitai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Bulk inserts and upserts with empty rows or no columns no longer include an empty columns parameter. Requests retain their POST method, body, and any specified conflict setting.

For list payloads, pre_insert and pre_upsert now add the columns query parameter only when the payload produces a nonempty unique-column string. Sync and async tests cover empty lists and lists containing an empty mapping. The tests also check that upsert requests retain on_conflict="id".

Change: Bug fix

Merge Risk: Minimal · up to 92dc3

Bulk inserts and upserts with no row keys no longer send an empty columns parameter that PostgREST rejects. Payloads with keys behave as before. No merge-blocking risk was identified.

- [ ] 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

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d6f1e6fa-f03a-40db-95ea-8ffad78f6648
Commits

Reviewing files that changed from the base of the PR and between cde16dc and 92dc34a.

Files selected for processing: 3

  • src/postgrest/src/postgrest/request_builder.py
  • src/postgrest/tests/_async/test_request_builder.py
  • src/postgrest/tests/_sync/test_request_builder.py

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

@spydon
spydon merged commit f80e732 into main Nov 13, 2026
29 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2763-empty-bulk-insert-columns branch November 13, 2026 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant