Skip to content

Conversation

grdsdev
Copy link
Contributor

@grdsdev grdsdev commented Sep 22, 2025

Summary

  • Implement maxAffected method equivalent to postgrest-js library
  • Sets maximum number of rows that can be affected by update and delete operations
  • Adds handling=strict and max-affected={value} to Prefer header

Implementation Details

  • Added maxAffected(int value) method to PostgrestTransformBuilder class
  • Preserves existing Prefer headers when adding maxAffected
  • Supports method chaining with other transform methods
  • No runtime validation - relies on documentation for proper usage guidance

Usage Examples

// Update with max affected rows limit
supabase.from('users').update({'active': false}).eq('status', 'inactive').maxAffected(5);

// Delete with max affected rows limit  
supabase.from('users').delete().eq('active', false).maxAffected(10);

// Method chaining
supabase.from('users').update({'status': 'INACTIVE'}).eq('id', 1).maxAffected(1).select();

Test Coverage

  • ✅ Unit tests for method availability and chaining
  • ✅ Integration tests validating HTTP headers using custom client
  • ✅ Tests for preserving existing Prefer headers
  • ✅ All existing tests continue to pass

Notes

  • Requires PostgREST v13 or higher
  • Only effective with PATCH and DELETE operations (documented in method docs)
  • When limit is exceeded, PostgREST will return an error

🤖 Generated with Claude Code

Add maxAffected method to PostgrestTransformBuilder that sets the maximum
number of rows that can be affected by update and delete operations.

- Add maxAffected method to PostgrestTransformBuilder class
- Set handling=strict and max-affected={value} in Prefer header
- Preserve existing Prefer headers when adding maxAffected
- Support method chaining with other transform methods
- Add comprehensive unit and integration tests
- Documentation notes PostgREST v13+ requirement

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@grdsdev grdsdev changed the title feat(postgrest): implement maxAffected method feat(postgrest): Implement maxAffected method Sep 22, 2025
@grdsdev grdsdev requested a review from a team September 22, 2025 08:58
@grdsdev grdsdev merged commit ae2d12d into main Sep 22, 2025
15 checks passed
@grdsdev grdsdev deleted the guilherme/clibs-379-supabase-flutter-implement-maxaffected-method branch September 22, 2025 14:10
grdsdev added a commit to supabase/supabase that referenced this pull request Sep 30, 2025
…dToken

Add documentation for two new features from supabase-flutter:

1. maxAffected() method (PR #1226)
   - Add API reference in supabase_dart_v2.yml spec
   - Document usage with update() and delete() operations
   - Include examples showing safety mechanism for limiting affected rows
   - Note PostgREST v13+ requirement

2. linkIdentityWithIdToken() method (PR #1206)
   - Add API reference in supabase_dart_v2.yml spec
   - Document native OAuth identity linking flow
   - Include Google and Apple Sign-In examples
   - Update auth-identity-linking.mdx guide with new section
   - Document supported providers and requirements

Updated files:
- apps/docs/spec/supabase_dart_v2.yml: Add maxAffected and linkIdentityWithIdToken API docs
- apps/docs/content/guides/auth/auth-identity-linking.mdx: Add native OAuth linking section

References:
- supabase/supabase-flutter#1226
- supabase/supabase-flutter#1206

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
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.

3 participants