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

and operator with same row does not work #394

Open
nazo6 opened this issue Sep 1, 2023 · 1 comment
Open

and operator with same row does not work #394

nazo6 opened this issue Sep 1, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@nazo6
Copy link

nazo6 commented Sep 1, 2023

Problem

I have data like this in Test table
image

And there is code to find data which contains "abc" and "def".

    let res = client
        .test()
        .find_many(vec![and(vec![
            test::title::contains("abc".to_string()),
            test::title::contains("def".to_string()),
        ])])
        .exec()
        .await
        .unwrap();

    dbg!(&res);

I assumed that this code shows

&res = [
    Data {
        id: 2,
        title: "abcdefgh",
    },
]

But actual output was below.

&res = [
    Data {
        id: 1,
        title: "defgh",
    },
    Data {
        id: 2,
        title: "abcdefgh",
    },
]

It seems like only last condition in and is applied. Also, this works as expected if whereparams are for different rows

Version

  • rust 1.71.0
  • prisma-client-rust 0.6.10
@Brendonovich
Copy link
Owner

Hmm, I suspect that the second contains is overwriting the first one. What you're trying to do may not actually be possible at the moment, I think the proper implementation of and would be something like this:

client
    .test()
    .find_many(vec![and![
        vec![test::title::contains("abc".to_string())]
        vec![test::title::contains("def".to_string())],
    ]])

Also note that I used and! which lets you combine the and and vec!.

@Brendonovich Brendonovich added the bug Something isn't working label Sep 4, 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