RobertCraigie / prisma-client-py

Prisma Client Python is an auto-generated and fully type-safe database client designed for ease of use
https://prisma-client-py.readthedocs.io
Apache License 2.0
1.86k stars 81 forks source link

Support schemas that are using the preview feature relationJoins on different generators #862

Open nettrino opened 9 months ago

nettrino commented 9 months ago

Problem

I am using the python prisma client in a project that uses a shared schema. That shema has the preview feature relationJoins enabled, which breaks prisma generate:

error: The preview feature "relationJoins" is not known. Expected one of: deno, driverAdapters, fullTextIndex, fullTextSearch, metrics, multiSchema, postgresqlExtensions, tracing, views

I am not currently using that feature in my codebase, and would rather not have to be forced to modify the schema on the fly if I can avoid it, especially since it is not used in this generate.

The schema generators are as follows:

generator client {
    provider        = "prisma-client-js"
    binaryTargets   = ["native"]
    previewFeatures = ["views", "multiSchema", "relationJoins"]
}

generator pythonclient {
    provider             = "prisma-client-py"
    interface            = "asyncio"
    recursive_type_depth = 5
    previewFeatures      = ["views", "multiSchema"]
}

generator goclient {
    provider        = "go run github.com/steebchen/prisma-client-go"
    previewFeatures = ["views", "multiSchema"]
}

/// Always after the prisma-client-js generator
generator json {
    provider        = "prisma-json-types-generator"
    // all type overwrites are defined in src/lib/db.ts
    previewFeatures = ["views", "multiSchema"]
}

Suggested solution

Allow prisma generate to proceed with a warning / force flag if the feature is not used in teh python provider

RobertCraigie commented 9 months ago

This is likely because the Prisma version is outdated, I haven't published a new release for the last couple Prisma versions. Could you try installing prisma-client-py from GitHub?

I'll hopefully be able to publish to pypi soon.