pinchbv / floor

The typesafe, reactive, and lightweight SQLite abstraction for your Flutter applications
https://pinchbv.github.io/floor/
Apache License 2.0
967 stars 191 forks source link

An extra space between "From" and "Table" in Stream query is causing issue in streamcontroller and the widget is not getting updated #736

Closed becjit closed 1 year ago

becjit commented 1 year ago

It seems really weird. I faced this in my project, so decided to try it with the official example. This is happening in both iphone and android emulators

Steps to reproduce:

  1. Launch the official example from floor repo.

  2. Add a task and save

  3. a) Expected behaviour: Count and listview both getting updated

  4. b) Actual behaviour: Same as above

  5. insert an extra space between "From" and Table in following query and save. You dont even need to run the build

  6. @Query('SELECT DISTINCT COUNT(message) FROM task') Stream<int?> findUniqueMessagesCountAsStream();

  7. Add a task and save

  8. a) Expected behaviour: Count and listview both getting updated 7.b) Actual behaviour: Listview is getting updated but not the count

Additional info: It's happening with other stream queries as well

Could someone confirm if they are seeing the same behaviour. I am feeling like I must be missing something

becjit commented 1 year ago

Without space

Screenshot 2023-02-15 at 9 30 03 PM

The count and number of items are same

With space

Screenshot 2023-02-15 at 9 30 37 PM

The count is 3 but the number of items is 4

dkaera commented 1 year ago

It's an interesting thing, and it certainly shouldn't be happening. Thanks for reporting the issue. I'll take a look what might be wrong.

dkaera commented 1 year ago

To be honest I wasn't able to replicate the issue. An extra space automatically removes in the generated code. Please take a look a sample code bellow.

About the point 5). The string value in the annotation is only used to generate code. Therefore, if you change the value in the Query annotation, you must run the code generator, otherwise there will be no effect from this change.

image

becjit commented 1 year ago

Thnx @dkaera let me see if it get fixed after running the build. I remember running the build but will double check.

becjit commented 1 year ago

@dkaera running build fixes it it seems. You can close it