-
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
add isRaw to Query annotation #315
base: develop
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #315 +/- ##
===========================================
- Coverage 90.08% 90.07% -0.01%
===========================================
Files 74 64 -10
Lines 1855 1673 -182
===========================================
- Hits 1671 1507 -164
+ Misses 184 166 -18
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Are you finished already and want a review or is this WIP? If its a work in progress, please convert this PR into a draft for now(The option should be somewhere on the right). |
@mqus Any better ideas to accomplish this feature? |
I think the architecture of floor (or room for that matter) is not well-suited for dynamic querying or query-building, but your approach can definitely work and be a middle ground/workaround for that. We could try to move to a more complex and powerful RawQuery like room has in the future (when the other building blocks for that are ready) but I think this is sufficient for now . What are your thoughts, @vitusortner ? |
@required final T Function(Map<String, dynamic>) mapper, | ||
}) async { | ||
final rows = await _database.rawQuery(sql, arguments); | ||
final rows = await (isRaw ? _database.rawQuery(sql.replaceAll('?', arguments[0])) : _database.rawQuery(sql, arguments)); |
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.
This behaviour (using multiple arguments with multiple ?
in a query will insert the first argument in all of them) can be pretty unexpected. please use all arguments for replacing and check if the number of ? and arguments match up.
@required final T Function(Map<String, dynamic>) mapper, | ||
}) async { | ||
final rows = await _database.rawQuery(sql, arguments); | ||
final rows = await (isRaw ? _database.rawQuery(sql.replaceAll('?', arguments[0])) : _database.rawQuery(sql, arguments)); |
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.
same as above.
# Conflicts: # floor_generator/lib/misc/constants.dart # floor_generator/lib/processor/query_method_processor.dart # floor_generator/lib/value_object/query_method.dart
I need this feature now, How can use your commit in my project? |
# Conflicts: # floor/lib/src/adapter/query_adapter.dart # floor_generator/lib/processor/query_method_processor.dart # floor_generator/lib/writer/database_writer.dart # floor_generator/lib/writer/query_method_writer.dart
Can achieve raw query like this:
and condition like: