Skip to content

fix(postgrest): keep bulk insert columns in first-seen order - #2045

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-1703-postgrest-bulk-insert-columns-query
Nov 13, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-1703-postgrest-bulk-insert-columns-query

Conversation

@spydon

@spydon spydon commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Summary

_unique_columns collected the keys of every row into a set, so the columns query parameter sent by bulk insert and upsert depended on string hashing, which is randomized per process through PYTHONHASHSEED. The same payload produced a different URL from run to run, which defeats HTTP caching and request signing and makes exact URL assertions flaky.

The keys are now deduplicated with dict.fromkeys, which keeps the order in which each column first appears across the rows.

Tests

  • test_unique_columns_reads_keys_from_every_mapping_row now asserts the exact string instead of comparing sets.
  • New test_unique_columns_keeps_first_seen_order covers keys repeated across rows in a different order.

Resolves SDK-1703

@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
    • Column lists now retain the order in which keys first appear across rows, providing consistent output.

_unique_columns now deduplicates JSON row keys while preserving their first-seen order. The tests assert the exact column string for mapping rows and check that repeated keys across rows do not change the order.

Change: Bug fix

Merge Risk: Minimal · up to 8a2c3

Bulk insert and upsert requests now produce a stable, deterministic columns query parameter. 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: a74b10be-cb00-441f-8c07-82445b4c4a76
Commits

Reviewing files that changed from the base of the PR and between 1217f42 and 8a2c38c.

Files selected for processing: 2

  • src/postgrest/src/postgrest/request_builder.py
  • src/postgrest/tests/test_unique_columns.py

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

@spydon
spydon merged commit efe7cf8 into main Nov 13, 2026
27 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-1703-postgrest-bulk-insert-columns-query branch November 13, 2026 13:11
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