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

Query return type #426

Closed
tajaouart opened this issue Nov 4, 2020 · 5 comments
Closed

Query return type #426

tajaouart opened this issue Nov 4, 2020 · 5 comments
Labels
duplicate This issue or pull request already exists

Comments

@tajaouart
Copy link

tajaouart commented Nov 4, 2020

I'm trying to return the number of rows in database but,
query method doesn't accept a String, int or Object as a return type other than my entities ??

ex:
@ Query('SELECT COUNT(id) FROM Question')
Future < String > getNumberOfQuestions();

Error:

NoSuchMethodError: The getter 'constructor' was called on null.
Receiver: null
Tried calling: constructor
[INFO] Running build completed, took 10.6s

[INFO] Caching finalized dependency graph...
[INFO] Caching finalized dependency graph completed, took 77ms

[SEVERE] Failed after 10.6s
pub finished with exit code 1

@vitusortner
Copy link
Collaborator

As of now, returning integers is not supported but we're working on something here #361.

@LuckyJayce
Copy link

LuckyJayce commented Dec 23, 2020

I think the return value will be more general if it can support the definition of map,and it will deal with the situation of multiple columns

@Query('SELECT COUNT(id) FROM Question')
Future<Map<String, dynamic>> getNumberOfQuestions();

@vitusortner
Copy link
Collaborator

This is already possible by using your database's database property. It gives access to the underlying SQLite (sqflite) database. https://github.com/vitusortner/floor/blob/1db7738395502ca06a0adabb8943e0750c01fd4d/floor/lib/src/database.dart#L14

@alectogeek
Copy link

This is already possible by using your database's database property. It gives access to the underlying SQLite (sqflite) database.

Yes, but only as a future. Sometimes it's useful to get COUNT() as Stream

@mqus
Copy link
Collaborator

mqus commented Apr 23, 2021

This is more or less the same issue as #200 so I'll close this as a duplicate of it. Please be sure to subscribe/enable notifications there to keep tabs on this feature.

@mqus mqus closed this as completed Apr 23, 2021
@mqus mqus added the duplicate This issue or pull request already exists label Apr 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Development

No branches or pull requests

5 participants