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

information #348

Open
daniloadorno opened this issue May 31, 2020 · 3 comments · May be fixed by #315
Open

information #348

daniloadorno opened this issue May 31, 2020 · 3 comments · May be fixed by #315
Labels
feature Request and implementation of a feature (release drafter)

Comments

@daniloadorno
Copy link

daniloadorno commented May 31, 2020

how to do?

@query(sql)
Future findBySql(String sql);

in .g.dart

@OverRide
Future findBySql(String sql) async {
return _queryAdapter.query(sql, mapper: _tMapper);
}

@mqus
Copy link
Collaborator

mqus commented Jun 1, 2020

Sadly we don't allow completely dynamic queries like yours. Your use-case might be an exception but generally this is also not a good idea because of sql-injections and other issues.

It might be possible to use @rawQuery/isRaw for this once it is implemented (see #315), but you will miss auto-updated Streams and static type validation, which can only be done on queries which are known at compile time.

@daniloadorno
Copy link
Author

is that in some cases it is necessary to take only one field, in other cases it is necessary to make a count, in other cases it is necessary to do sum, the dynamic query would greatly decrease the creation of methods.

@daniloadorno
Copy link
Author

I made this implementation to give me this power:

ex:

Future<List> findListBySql(String sql) async {
final rows = await dbHelper.database.rawQuery(sql);
return rows.map((row) => Account.fromJson(row)).toList();
}

@mqus mqus added the feature Request and implementation of a feature (release drafter) label Jul 12, 2020
@mqus mqus linked a pull request Jul 12, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Request and implementation of a feature (release drafter)
Development

Successfully merging a pull request may close this issue.

2 participants