Skip to content

fix(postgrest): Update parameter type of match() filter so that null values cannot be passed. #919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 13, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/postgrest/lib/src/postgrest_filter_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder<T> {
/// .select()
/// .eq('username', 'supabot');
/// ```
///
/// For `null` equality, use [isFilter] instead.
PostgrestFilterBuilder<T> eq(String column, Object value) {
final Uri url;
if (value is List) {
Expand Down Expand Up @@ -478,8 +480,10 @@ class PostgrestFilterBuilder<T> extends PostgrestTransformBuilder<T> {
/// });
/// ```
PostgrestFilterBuilder<T> match(Map query) {
assert(!query.values.contains(null),
'`null` equality does not work with match. Use isFilter instead.');
var url = _url;
query.forEach((k, v) => url = appendSearchParams('$k', 'eq.$v', url));
query.forEach((k, v) => url = appendSearchParams(k, 'eq.$v', url));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might be good to undo this.

Suggested change
query.forEach((k, v) => url = appendSearchParams(k, 'eq.$v', url));
query.forEach((k, v) => url = appendSearchParams('$k', 'eq.$v', url));

return copyWithUrl(url);
}
}
Loading