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

Bug: CreateMany Returns Error Complaining "Argument skipDuplicates Does Not Exist On Enclosing Type" #173

Closed
Congyuwang opened this issue Oct 11, 2022 · 5 comments · Fixed by #174

Comments

@Congyuwang
Copy link
Contributor

Congyuwang commented Oct 11, 2022

Calling create_many() returns this error:

Error executing query: P2009 - Failed to validate the query: `Argument does not exist on enclosing type.` at `Mutation.createManyLocation.skipDuplicates`

function called: client.location().create_many(many_data).exec().await?

prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", tag = "0.6.1" }

Here is a minimal example Repo to reproduce the problem: https://github.com/Congyuwang/rust-prisma-create-many-debug

The model in the example looks like this:

generator client {
  provider = "cargo prisma"
  output   = "../src/prisma.rs"
}

datasource db {
  provider = "mongodb"
  url      = env("DB_URL")
}

model Location {
  id          String @id @default(auto()) @map("_id") @db.ObjectId
  description String
}

The main function looks like this:

pub mod prisma;

#[tokio::main]
async fn main() {
    dotenv::dotenv().unwrap();
    let client = prisma::new_client().await.unwrap();
    client.location().create_many(vec![
        ("a".to_string(), vec![]),
        ("b".to_string(), vec![]),
        ("c".to_string(), vec![]),
    ]).exec().await.unwrap();
}

To reproduce, clone the repo https://github.com/Congyuwang/rust-prisma-create-many-debug, add a mongodb DB_URL and cargo run --release.

@Brendonovich
Copy link
Owner

Hmm, forgot that skipDuplicates isn't available everywhere. Will need to make that a database-specific feature.

@Congyuwang
Copy link
Contributor Author

Congyuwang commented Oct 11, 2022

Right. According to https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#createmany: skipDuplicates is only supported by databases that support ON CONFLICT DO NOTHING. Perhaps this means it's supported only by Postgres?

@Brendonovich
Copy link
Owner

Brendonovich commented Oct 11, 2022

The availability of skip_duplicates is defined by the CreateSkipDuplicates capability, which is hardcoded on each connector. The generator and runtime will need to check whether the capability is available on the current connector.
EDIT: Though, skip_duplicates is something only in the library, so checking the capabilities may not be possible and we may have to do it based on features.

@Congyuwang
Copy link
Contributor Author

attempted fix using feature: Fix #174

@Brendonovich Brendonovich added this to the 0.6.3 milestone Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants