-
Notifications
You must be signed in to change notification settings - Fork 192
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
Return null on scalar queries such as "Select count(*) from ..." #576
Comments
I have the same problem. The following query @Query('SELECT MAX(createdAt), MAX(updatedAt) from people')
Future<List<DateTime>> getOldestDates(); generates following code in await _queryAdapter
.queryNoReturn('SELECT MAX(createdAt), MAX(updatedAt) from people'); which has a return type of |
What about removing @Query('SELECT COUNT(*) from Area')
Future<int> total(); I suppose |
He can't. If you do that and try to run
|
What about max (id) when db is empty? |
This is badly needed feature. I have several tables I'd like to know if they are empty or not. My workaround is to have raw queries in the
But this is sooo ugly and might not be robust! I think count is common enough to be supported along with CRUD. |
This feature will help #200 |
No matter how you spin it around the code generator portion needs to recognize and support what you want to do. And that's what is missing right now. |
stranger still int? count=await database.myItemDAO.getAllCount(); List myItems= await database.myItemDAO.findAllItems(); |
That length on the findAllItems result is very resource intensive especially with a larger table. First I would say just for this purpose you may want
|
The auto-generated code for SELECT COUNT(*) is _queryAdapter.queryNoReturn, so you won't get any result. dao code:
My solution:
The raw sql result is a map: {'COUNT(*)': value}, so you just write the mapper to get the value is ok. |
The following query always returns null:
I have tested other scalar queries, such as
still got null. very strange.
The text was updated successfully, but these errors were encountered: