Repository navigation
perf(postgrest): stop wrapping every inserted and upserted row in a cast view - #2058
Conversation
…odies to UTF-8 bytes on the calling isolate in slices
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Row normalization and mutation tests packages/postgrest/lib/src/postgrest_query_builder.dart, packages/postgrest/test/insert_builder_test.dart |
_jsonRow returns existing Map<String, dynamic> values directly and copies other maps with string keys. Tests check serialized request bodies, the columns parameter, and ArgumentError for non-String keys in insert() and upsert(). |
Priority:
Estimated code review effort: 2 (Simple) | ~8 minutes
Change: Refactor
Possibly related PRs
- supabase/supabase-flutter#1940: Adds typed table inserts and upserts through
PostgrestQueryBuilder, which contains the changed_jsonRowpath. - supabase/supabase-flutter#2057: Changes the PostgREST mutation request-body encoding path that receives the rows handled by this PR.
Suggested reviewers: androidpoet
Merge Risk: 
Minimal · up to f0171
-
No actionable issue is established; the change is mergeable after normal checks.
Pre-merge checks: 
5
-
Full details: Docstring Coverage
-
Explanation
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0 files. (2 skipped: 2 unsupported.)
-
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.
Comment @coderabbitai help to get the list of available commands.
…apping-every-inserted-and-upserted-row
Stacked on #2057.
Fixes SDK-2402.
Summary
_jsonRow, whichinsert()andupsert()(and the typedinsertAll/upsertAll) use to turn each row of a list into a JSON object, ended withjson.cast().Map.castalways returns a wrapping view, even when the row already is aMap<String, dynamic>, so the key check, thecolumnscollection,jsonEncodeand the copy of the body to the encoding isolate all went through a type-checking view.Rows that already are a
Map<String, dynamic>are now returned as they are. Other maps with only String keys are copied once withMap.from. A row with a non-String key still throwsArgumentError.Measured with a canned HTTP transport, AOT compiled, on macOS arm64:
Tests
insert()andupsert()of a list holding aMap<dynamic, dynamic>and aMap<String, Object?>send the right body andcolumnsparameter, and a row with a non-String key throws.Summary by CodeRabbit
ArgumentError.