Skip to content
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

Upgrading to 1.0.0-dev.83 cause previously working queries to fail #7

Closed
gmarizy opened this issue Feb 10, 2024 · 16 comments
Closed

Upgrading to 1.0.0-dev.83 cause previously working queries to fail #7

gmarizy opened this issue Feb 10, 2024 · 16 comments

Comments

@gmarizy
Copy link
Contributor

gmarizy commented Feb 10, 2024

Expected Behavior

Same behavior between 1.0.0-dev.82 and 1.0.0-dev.83

Actual Behavior

Some requests fail with error like "You cannot use '!=' filters more than once", even in request where there is only isEqualTo where clauses, after updating to 1.0.0-dev.83.

Steps to Reproduce the Problem

  1. Update cloud_firestore_odm from 1.0.0-dev.82 to 1.0.0-dev.83
  2. flutter pub run build_runner build --delete-conflicting-outputs
  3. run app

Specifications

  • Version: 1.0.0-dev.83 (and cloud_firestore either 4.14.0 or 4.15.4)
  • Platform: Android
@gmarizy gmarizy changed the title Upgrading to 1.0.0-dev.83 cause a bunch of previously working queries to fail Upgrading to 1.0.0-dev.83 cause previously working queries to fail Feb 10, 2024
@becjit
Copy link

becjit commented Feb 10, 2024

+1
for me it does not return any results

@dorklein
Copy link
Contributor

All my where queries return no result

@becjit
Copy link

becjit commented Feb 21, 2024 via email

@FXschwartz
Copy link

FXschwartz commented Feb 22, 2024

Same here. All get queries using any kind of .where now return 0 results with no error.

final configs = await configurationRef
          .whereCreatedBy(isEqualTo: userId)
          .wherePartNumber(isEqualTo: partNumber)
          .whereDeleted(isEqualTo: false)
          .get();

Switching to direct queries works

@FXschwartz
Copy link

@rrousselGit This looks to be a pretty nasty bug. Do you have some free time to take a look? It might be related to the recent isEqual change.

@mmatook
Copy link

mmatook commented Feb 25, 2024

I can confirm this behavior.
Turning on debug logging for cloud_firestore shows why the odm queries dont return results.

In my case the generated query with where clause is containing duplicated query fields with each a valid value and a null value using the AND operator. This is not limited to only to isEqual.

Duplicated query fields with null in bold below.

(24.10.1) [QueryEngine]: Using full collection scan to execute query: Query(target=Query(test_collection where created_by==X3xty1MuGBhb951AQ27p54WIU9p2 and created_by==null and is_completed==true and is_completed==null and expires_date>=time(1708821339,589398000) and expires_date!=null order by expires_date, name);limitType=LIMIT_TO_FIRST)

@rrousselGit My best guess is the _WhereMapper is doing double duty with broken logic.

@urbanmania
Copy link

I have created a sample project you can use to reproduce this, if that helps.

https://github.com/urbanmania/test_project

If you run it as is you will get the error.

If you comment out this line the error is gone (but also the access control) https://github.com/urbanmania/test_project/blob/0931902c0feb202212a792f9cffe33d74363cd85/lib/main_list_view.dart#L15

It is not the first time I've seen this error, previously it broke and then magically got fixed but broke again with the latest update.

@mmatook
Copy link

mmatook commented Mar 4, 2024

It appears no maintainer is actively watching this project anymore since the transfer ...
While beeing under firebase/flutterfire there was at least some kind of action.

To me it looks like an abandoned project.

@rrousselGit
Copy link
Contributor

It isn't abandoned by any means. It's not receiving any more or less updates than before.
The previous "weekly release" was just an automatic one made when Firebase was released – bumping side-packages alongside it.
Now that it's in a separate repo, the automatic release doesn't happen anymore, that's all.

There's no real bug here. It's because your ODM version is higher than your Firestore version. You use firestore <4.15.0, but the latest ODM.

I'll bump the minimum Firestore version necessary to fix – and fix a bug specific to arrayContains. But otherwise, it's working well.

@gmarizy
Copy link
Contributor Author

gmarizy commented Mar 4, 2024

@rrousselGit my ODM version is not higher than my firestore version; as written in the initial issue, I produce the bug with cloud_firestore version 4.15.4.

I tested again with:
cloud_firestore_odm: 1.0.0-dev.83
cloud_firestore: 4.15.6
and:
cloud_firestore_odm: 1.0.0-dev.84
cloud_firestore: 4.15.6

The bug is still there.

@rrousselGit
Copy link
Contributor

You're right, there is a separate issue specifically with how the ODM passes isNull. I'll fix it

@gmarizy
Copy link
Contributor Author

gmarizy commented Mar 4, 2024

I confirm it's fixed, thank you @rrousselGit.

As a side note, I don't know if it's intended but there is a discrepancy of version between cloud_firestore_odm which stayed 1.0.0-dev.84 while cloud_firestore_odm_generator have been pushed to 1.0.0-dev.85.

@mmatook
Copy link

mmatook commented Mar 8, 2024

Confirming this issue is fixed ! Thx @rrousselGit !

@ciriousjoker
Copy link

ciriousjoker commented Mar 13, 2024

Not quite sure why, but this isn't fixed for us.
Downgrading to 82 helps, but 84 isn't working.

Some sample code:

SomeCollectionReference(firestore)
      .whereFieldPath(FieldPath(const ["creator"]), isEqualTo: uid)
      .snapshots()

SomeCollectionReference(firestore)
      .whereCreator(isEqualTo: uid)
      .snapshots()

Both of these stopped working, creator is a string field, uid is guaranteed to not be null.

@gmarizy
Copy link
Contributor Author

gmarizy commented Mar 14, 2024

@ciriousjoker dev version 84 of generator is flawed, you have to use the 85.

In my pubspeck.yaml:

cloud_firestore_odm: 1.0.0-dev.84
cloud_firestore_odm_generator: 1.0.0-dev.85

After upgrading and flutter pub get I just run flutter pub run build_runner build --delete-conflicting-outputs and it was all good.

@ciriousjoker
Copy link

@gmarizy ah yes thanks! Forgot to regenerate the files after updating. Now it's working!

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

No branches or pull requests

8 participants