-
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
Feature: Add support for @DatabaseView annotations #262
Conversation
The test that's currently failing is the same as in #259 and as far as I can tell, this fails even on the current |
At a first glance, this looks great 🎉 Thanks for your contribution! I'll review the full PR as soon as possible. |
Some remarks about hacks I did and shouldn't change back myself right now:
I also messed up my branches a bit when starting out so view_processor.dart already checks for Uint8List, even if the whole rest of the code can't do anything with it. If you want to merge this PR before #259, I'll remove it. If #259 comes first, I'll rebase and use the proper getter there. |
No problem. Normally, I only change the paths of the library's packages to point to the versions available on pub while creating a release. I must have forgotten to revert it to referring the local version. You can leave it as it is.
Let's merge #259 before. |
I rebased the PR onto the current develop branch and altered |
Codecov Report
@@ Coverage Diff @@
## develop #262 +/- ##
===========================================
- Coverage 81.27% 80.66% -0.62%
===========================================
Files 51 48 -3
Lines 1383 1298 -85
===========================================
- Hits 1124 1047 -77
+ Misses 259 251 -8
Continue to review full report at Codecov.
|
So, I rebased to the current develop and added some more tests (CodeCov seems to work even for PRs now, nice :) ) There is only one open question for me now:
PS: Ah, right, I should document the DatabaseView usage in the README, or do you want to do it yourself? Edit: I meant Streams. Fixed the comment to make more sense. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've started a review a couple days ago. I'll just post the current progress now and will end the review sometime soon.
Thank you! I wont disrupt you then ;). Regarding Streams: Afaict Room seems to take the first option and includes a whole sqlite parser... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking pretty good! I've left some comments and I'm excited for your input.
This adds initial support for @DatabaseView annotations known from room. One test was added, further testing is needed. Implements pinchbv#130. fix linting error
- Do not allow queries from views to be streamed - throw error if a user tries to do that and test that error - remove Stream<> queries from DAO in integration test - getStreamEntities will only return entities again - Create new Superclass for EntityProcessor and ViewProcessor named QueryableProcessor to deduplicate common functions - Code cleanup - clean up integration tests - improve code layout and comment wording in annotations, DatabaseProcessor, QueryMethodProcessor - fix toString and hashCode methods in Database (value object) - improve error message wording in DatabaseViewError
I rebased, integrated most of the suggestions and added an exception if a library user will try to use a Dao method which will stream the results of a query on a database view. |
import 'package:floor_generator/value_object/deletion_method.dart'; | ||
import 'package:floor_generator/value_object/entity.dart'; | ||
import 'package:floor_generator/value_object/insertion_method.dart'; | ||
import 'package:floor_generator/value_object/query_method.dart'; | ||
import 'package:floor_generator/value_object/transaction_method.dart'; | ||
import 'package:floor_generator/value_object/update_method.dart'; | ||
|
||
import 'entity.dart'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡We could get rid of all the unnecessary import qualifiers.
import 'deletion_method.dart';
import 'entity.dart';
import 'insertion_method.dart';
import 'query_method.dart';
import 'transaction_method.dart';
import 'update_method.dart';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then we should do it everywhere... but I think this should be part of another PR... I'll just put the entity import back where it was for now to make int consistent with the other statements...
- Clean up small details in code, according to the review - Improve tests - Simplify integration tests - split off and merge common QueryableProcessor tests into a separate file - move createClassElement function, which is now used in three test files to testutils - Add documentation to README.md
I adopted the suggestions from the review and added some documentation to the README files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍Thanks for this contribution!
@vitusortner When this feature will be available as a release? |
We've just created a new release with the version 0.12.0, which makes database views available and includes other features, fixes and improvements. |
This adds support for @DatabaseView annotations known from room. One test was added, further testing is needed. Implements #130. I tried to do minimal adjustments to the codebase while copying the handling of entities. I took over the Field handling from there and then just ignored the nullable property by implementing the createStatement function differently.
As I already said in #259, I may have no idea what I'm doing, so please tell me if I did something wrong or if I can do something better.
I'll try to add some more tests before this is ready to merge. Are there some specific things you would like to see tested?