Skip to content

use diesel_async::RunQueryDsl::execute conflicts with meilisearch_sdk execute #114

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

Closed
1 task
javihc opened this issue Sep 28, 2023 · 5 comments
Closed
1 task
Labels
bug Something isn't working

Comments

@javihc
Copy link

javihc commented Sep 28, 2023

Setup

Versions

  • Rust: 1.72.1
  • Diesel: 2.1.1
  • Diesel_async: 0.4.1
  • Database: Postgres 15
  • Operating System: Arch

Feature Flags

  • diesel: ["postgres", "chrono", "uuid"]
  • diesel_async:["postgres", "bb8"]

Problem Description

I'm using meilisearch and postgres for an API using axum and when I use meilisearch with the code:

let results = meilisearch_client
                .index("programs")
                .search()
                .with_query(&query)
                .with_limit(pagination.limit.into())
                .execute()
                .await?;

I have and error:

error[E0277]: the trait bound `&mut SearchQuery<'_>: QueryFragment<_>` is not satisfied
   --> src/controllers/programs.rs:66:18
    |
66  |                 .execute()
    |                  ^^^^^^^ the trait `QueryFragment<_>` is not implemented for `&mut SearchQuery<'_>`
    |
    = help: the following other types implement trait `QueryFragment<DB, SP>`:
              <diesel_async::pg::TransactionBuilder<'a, C> as QueryFragment<Pg>>
              <Box<T> as QueryFragment<DB>>
              <DeleteStatement<T, U, Ret> as QueryFragment<DB>>
              <FromClause<F> as QueryFragment<DB>>
              <BoxedLimitOffsetClause<'a, Pg> as QueryFragment<Pg>>
              <query_builder::select_clause::DefaultSelectClause<QS> as QueryFragment<DB>>
              <BoxedSqlQuery<'_, DB, Query> as QueryFragment<DB>>
              <query_builder::where_clause::BoxedWhereClause<'a, DB> as QueryFragment<DB>>
            and 384 others
    = note: required for `&mut SearchQuery<'_>` to implement `diesel_async::methods::ExecuteDsl<_, _>`
note: required by a bound in `diesel_async::RunQueryDsl::execute`
   --> /home/user/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/diesel-async-0.4.1/src/run_query_dsl/mod.rs:222:15
    |
219 |     fn execute<'conn, 'query>(self, conn: &'conn mut Conn) -> Conn::ExecuteFuture<'conn, 'query>
    |        ------- required by a bound in this associated function
...
222 |         Self: methods::ExecuteDsl<Conn> + 'query,
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `RunQueryDsl::execute`


The compiler things that the execute() of meilisearch is the execute() from diesel_async::RunQueryDsl.

What are you trying to accomplish?

Execute the meilisearch sdk query.
I'm using meilisearch-sdk = "0.24.2"

What is the expected output?

What is the actual output?

Are you seeing any additional errors?

Steps to reproduce

Checklist

  • [ X] I have already looked over the issue tracker for similar possible closed issues.
  • [ X] This issue can be reproduced on Rust's stable channel. (Your issue will be
    closed if this is not the case)
  • This issue can be reproduced without requiring a third party crate
@javihc javihc added the bug Something isn't working label Sep 28, 2023
@weiznich
Copy link
Owner

Thanks for writing this bug report. Can you explain why you believe that this is an issue in diesel_async and not in meilisearch or your code? Otherwise I would argue that this is "just" normal rust name resolution behavior which uses methods from traits in scope.

@javihc
Copy link
Author

javihc commented Sep 28, 2023

I think it's the diesel because meilisearch doesn't use traits. I don't know if it has anything to do with it but when I used diesel::RunQueryDsl I didn't have this error.

And also I get this error:

error[E0107]: method takes 0 generic arguments but 1 generic argument was supplied
   --> src/controllers/programs.rs:72:18
    |
72  |                 .execute::<SimpleSearchField>()
    |                  ^^^^^^^ expected 0 generic arguments
    |
note: method defined here, with 0 generic parameters
   --> /home/user/.local/share/cargo/registry/src/index.crates.io-6f17d22bba15001f/diesel-async-0.4.1/src/run_query_dsl/mod.rs:219:8
    |
219 |     fn execute<'conn, 'query>(self, conn: &'conn mut Conn) -> Conn::ExecuteFuture<'conn, 'query>
    |        ^^^^^^^
help: consider moving this generic argument to the `RunQueryDsl` trait, which takes up to 1 argument
    |
67  ~             let results = diesel_async::RunQueryDsl::<SimpleSearchField>::execute(meilisearch_client
68  +                 .index("programs")
69  +                 .search()
70  +                 .with_query(&query)
71  +                 .with_limit(pagination.limit.into()))
    |
help: remove these generics
    |
72  -                 .execute::<SimpleSearchField>()
72  +                 .execute()
    |


@weiznich
Copy link
Owner

In that case: Please provide a minimal reproducible example of your issue. Also include information about all relevant crate versions/rustc version/…. Otherwise this issue is not actionable.

@javihc
Copy link
Author

javihc commented Sep 28, 2023

I create a example with the issue.

https://gist.github.com/javihc/1ae50c1d88c75628c21d33d3eafdd33c

@weiznich
Copy link
Owner

Thanks for providing this example. I still do not see how that is diesel related. In my view that's just how rusts name resolution works, which means if a trait is in scope and rustc believes it applies the relevant trait method is used. If you believe that's the wrong behavior please raise this issue in the compiler repository. There is nothing that diesel or diesel_async could do to change language level behavior.

To give you a workaround: You cannot import diesel_async::RunQueryDsl in the same scope where you want to call the execute method from meilisearch.

Closed as this is not actionable on diesels side.

@weiznich weiznich closed this as not planned Won't fix, can't repro, duplicate, stale Sep 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants