Skip to content

🐛 [cloud_firestore] sentinel value breaks wrappers #12130

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

Closed
cedvdb opened this issue Jan 8, 2024 · 2 comments · Fixed by #12164
Closed

🐛 [cloud_firestore] sentinel value breaks wrappers #12130

cedvdb opened this issue Jan 8, 2024 · 2 comments · Fixed by #12164
Labels
plugin: cloud_firestore resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working

Comments

@cedvdb
Copy link

cedvdb commented Jan 8, 2024

Bug report

Following this issue a "sentinel value" was added to query parameters.

From:

  Query<Map<String, dynamic>> where(
    Object fieldOrFilter, {
    Object? isEqualTo,
    Object? isNotEqualTo,
    Object? isLessThan,
    Object? isLessThanOrEqualTo,
    Object? isGreaterThan,
    Object? isGreaterThanOrEqualTo,
    Object? arrayContains,

To:

    Object? isEqualTo = notSetQueryParam,
    Object? isNotEqualTo = notSetQueryParam,
    Object? isLessThan = notSetQueryParam,
    Object? isLessThanOrEqualTo = notSetQueryParam,
    Object? isGreaterThan = notSetQueryParam,
    Object? isGreaterThanOrEqualTo = notSetQueryParam,
    Object? arrayContains = notSetQueryParam,

However this is a breaking change for any kind of wrapper as null will be passed:

  AppQuery<T> where(
    AppFieldPath fieldPath, {
    Object? isEqualTo,
    Object? isNotEqualTo,
    Object? isLessThan,
    Object? isLessThanOrEqualTo,
    Object? isGreaterThan,
    Object? isGreaterThanOrEqualTo,
    Object? arrayContains,
    Iterable<Object?>? arrayContainsAny,
    Iterable<Object?>? whereIn,
    Iterable<Object?>? whereNotIn,
    bool? isNull,
  }) {
    final queryRef = _ref.where(
      fieldPath.toFirestore(),
      isEqualTo: isEqualTo,
      isNotEqualTo: isNotEqualTo,
      isLessThan: isLessThan,
      isLessThanOrEqualTo: isLessThanOrEqualTo,
      isGreaterThan: isGreaterThan,
      isGreaterThanOrEqualTo: isGreaterThanOrEqualTo,
      arrayContains: arrayContains,
      arrayContainsAny: arrayContainsAny,
      whereIn: whereIn,
      whereNotIn: whereNotIn,
      isNull: isNull,
    );
    // ...

I believe this (breaking) change was not required since there is already a isNull parameter. Exposing notSetQueryParam to the public api doesn't sound too good, so if that previous change wasn't necessary I suggest reverting those changes as this will be a breaking change for libraries wrapping firebase. For instance fake_cloud_firestore has diverged in behavior from cloud firestore.

Note: The dart default parameter proposal would have been helpful here

@cedvdb cedvdb added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Jan 8, 2024
@darshankawar darshankawar added the triage Issue is currently being triaged. label Jan 9, 2024
@darshankawar
Copy link

/cc @Lyokone

@darshankawar darshankawar added plugin: cloud_firestore and removed Needs Attention This issue needs maintainer attention. triage Issue is currently being triaged. labels Jan 9, 2024
@russellwheatley
Copy link
Member

Hey @cedvdb, thanks for the update. Upon review, we have decided that this does constitute a breaking change and will roll this back in the next release 🙏

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
plugin: cloud_firestore resolution: fixed A fix has been merged or is pending merge from a PR. type: bug Something isn't working
Projects
None yet
3 participants