fix: v0.5.3 — PR review fixes (orderBy consistency, redundant casts) - #40
Merged
Conversation
- Remove redundant `as` casts after `is` checks (Dart type promotion) - Add List orderBy support to findFirstRaw (was Map-only, now matches findManyRaw) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Code Review
This pull request updates the Prisma Flutter Connector to version 0.5.3, removing redundant type casts and adding support for List-based orderBy in findFirst queries. The reviewer suggests refactoring the orderBy type-checking logic into if-else if chains to improve code clarity and performance by explicitly handling the mutually exclusive nature of the types.
Comment on lines
+204
to
+206
| if (orderBy is Map<String, dynamic>) queryBuilder.orderBy(orderBy); | ||
| if (orderBy is List) queryBuilder.orderBy(orderBy); | ||
| if (orderBy is ${m}OrderByInput) queryBuilder.orderBy(_orderByToJson(orderBy as ${m}OrderByInput)); | ||
| if (orderBy is ${m}OrderByInput) queryBuilder.orderBy(_orderByToJson(orderBy)); |
There was a problem hiding this comment.
For clarity and minor performance improvement, it's better to use an if-else if chain here. Since orderBy can only be one of these types at a time, this structure more clearly communicates the exclusive nature of these checks.
if (orderBy is Map<String, dynamic>) queryBuilder.orderBy(orderBy);
else if (orderBy is List) queryBuilder.orderBy(orderBy);
else if (orderBy is ${m}OrderByInput) queryBuilder.orderBy(_orderByToJson(orderBy));
Comment on lines
+272
to
273
| if (orderBy is Map<String, dynamic>) queryBuilder.orderBy(orderBy); | ||
| if (orderBy is List) queryBuilder.orderBy(orderBy); |
There was a problem hiding this comment.
Comment on lines
+310
to
+311
| if (orderBy is Map<String, dynamic>) queryBuilder.orderBy(orderBy); | ||
| if (orderBy is List) queryBuilder.orderBy(orderBy); |
There was a problem hiding this comment.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Addresses 3 review comments from PR #39:
findFirstRawnow supportsListorderBy for multi-column sorting (wasMap-only, inconsistent withfindManyRaw)as Map<String, dynamic>casts infindManyorderBy (Dart type promotion handles it)as Map<String, dynamic>cast infindManyRaworderByTest plan
flutter analyze --fatal-infos— zero issuesdart format --set-exit-if-changed .— zero changes🤖 Generated with Claude Code