Skip to content

fix(postgrest): replace SCREAMING_SNAKE_CASE HTTP method constants with enum#1347

Merged
grdsdev merged 7 commits intomainfrom
grdsdev/fix-postgrest-http-method-case
Apr 7, 2026
Merged

fix(postgrest): replace SCREAMING_SNAKE_CASE HTTP method constants with enum#1347
grdsdev merged 7 commits intomainfrom
grdsdev/fix-postgrest-http-method-case

Conversation

@grdsdev
Copy link
Copy Markdown
Contributor

@grdsdev grdsdev commented Apr 2, 2026

Summary

  • Replaces six file-private METHOD_* string constants with a _HttpMethod enum that exposes a .value getter returning the uppercase string
  • Removes the // ignore_for_file: constant_identifier_names suppression
  • Removes the _Nullable<T> typedef, replacing its single use with a _typeOf<T>() helper for runtime nullable type comparison

Changes

  • postgrest_builder.dart: Adds _HttpMethod enum and _typeOf<T>() helper; removes constants, typedef, and lint suppression; updates all internal usages
  • postgrest_query_builder.dart: Updates method: arguments from string constants to enum values
  • postgrest_rpc_builder.dart: Same
  • postgrest_transform_builder.dart: Same

Root Cause

postgrest_builder.dart used SCREAMING_SNAKE_CASE top-level constants to represent HTTP method strings, requiring a file-level lint suppression (constant_identifier_names). These are private to the library and have no public API impact.

Testing

  • dart analyze — no issues
  • dart test --name "Custom http client" — 4/4 pass (integration tests require a live PostgREST server not available in CI without Docker)

Acceptance Criteria

  • constant_identifier_names lint passes with no file-level suppression
  • _Nullable typedef removed
  • No public API change (all changes are private)
  • All available tests pass

Linear Issue

Closes: SDK-810


🤖 Generated with Claude Code /take

…th enum

Replace six file-private HTTP method string constants with a private
_HttpMethod enum that has a .value getter for the uppercase string.
Remove the ignore_for_file lint suppression and the unused _Nullable
typedef (replaced with a _typeOf<T>() helper for the nullable type
comparison at runtime).

Closes: SDK-810

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions github-actions Bot added the postgrest This issue or pull request is related to postgrest label Apr 2, 2026
@grdsdev grdsdev requested review from a team and Vinzent03 April 2, 2026 18:17
String get value => name.toUpperCase();
}

typedef _Nullable<T> = T?;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm really unsure about this change. I implemented that and was a strange required hack to work with nullability and generics. The tests do pass, but I'm not totally sure that case is covered. Is there any specific reason to change this here?

Keep the original _Nullable<T> hack for the nullable type comparison
since it was an intentional workaround for Dart generics and its
removal was not strictly required.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev requested a review from Vinzent03 April 6, 2026 14:14
@grdsdev
Copy link
Copy Markdown
Contributor Author

grdsdev commented Apr 6, 2026

Reverted the _Nullable_typeOf change — the typedef is back as-is. The PR now only replaces the METHOD_* constants with the _HttpMethod enum. @Vinzent03 could you take another look?

Resolve conflict in postgrest_builder.dart: keep _HttpMethod enum
comparison while adopting main's removal of _schema null assertion.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
grdsdev and others added 4 commits April 6, 2026 11:31
The pre-commit dart formatter hook incidentally reformatted this file
during the merge commit. Restore it to main's unmodified version since
this PR only touches postgrest.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Resolve conflicts in postgrest_builder.dart: keep _HttpMethod enum
comparisons while adopting main's execHeaders local copy, send-function
pattern, and _executeWithRetry retry logic. Update _executeWithRetry
signature to accept _HttpMethod instead of String.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@grdsdev grdsdev merged commit 13e8b39 into main Apr 7, 2026
15 checks passed
@grdsdev grdsdev deleted the grdsdev/fix-postgrest-http-method-case branch April 7, 2026 19:25
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.

3 participants