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

[0.6.0] Arguments mapped incorrectly in raw query #224

Closed
abhinavc opened this issue Dec 6, 2019 · 2 comments · Fixed by #509
Closed

[0.6.0] Arguments mapped incorrectly in raw query #224

abhinavc opened this issue Dec 6, 2019 · 2 comments · Fixed by #509
Labels
feature Request and implementation of a feature (release drafter)

Comments

@abhinavc
Copy link

abhinavc commented Dec 6, 2019

Hi Vitus,
Using the same example as in #223, I also noticed that arguments were being mapped positionally and not as per the names they were given in the query

So, the following in the DAO

@Query("update sports set rating = :rating, has_target = :hasTarget, "
      "num_results = :numResults where id = :id")
  Future<void> update(int id, int rating, bool hasTarget, int numResults);

results in the following

@override
  Future<void> update(
      int id, int rating, bool hasTarget, int numResults) async {
    await _queryAdapter.queryNoReturn(
        'update sports set rating = ? has_target = ? num_results = ? where id = ?',
        arguments: <dynamic>[id, rating, hasTarget, numResults]);
  }

The issue is with arguments. It should be arguments: <dynamic>[rating, hasTarget, numResults, id]

I have been assuming that the query string in DAO is parsed and the names of the arguments are used to find which goes where. Thus far, my queries have been simple, single-argument
queries. Hence this issue didn't show. But it did when I wrote my first multi-argument query.

Thanks
Abhinav.

mqus pushed a commit that referenced this issue May 5, 2020
@mqus mqus added the feature Request and implementation of a feature (release drafter) label May 5, 2020
@mqus
Copy link
Collaborator

mqus commented May 5, 2020

This is roughly the same feature as #142 .

@jonasN5
Copy link
Contributor

jonasN5 commented Nov 22, 2020

This is still an issue, lost an hour until I figured out I had to position the arguments according to the query usage order.

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.

3 participants