prisma / prisma

Next-generation ORM for Node.js & TypeScript | PostgreSQL, MySQL, MariaDB, SQL Server, SQLite, MongoDB and CockroachDB
https://www.prisma.io
Apache License 2.0
38.74k stars 1.52k forks source link

Tyepscript: Property 'join' does not exist on type 'typeof Prisma' #17022

Open CaseyHaralson opened 1 year ago

CaseyHaralson commented 1 year ago

Bug description

I'm using Prisma in a typescript project and the join function is causing the file to fail compilation with: Property 'join' does not exist on type 'typeof Prisma'

I referenced this from the documentation: https://www.prisma.io/docs/concepts/components/prisma-client/raw-database-access#tagged-template-helpers

How to reproduce

Copy the following in to a Typescript file:

import { Prisma, PrismaClient } from "@prisma/client";

export function test() { const pc = new PrismaClient(); const results = pc.$queryRawselect A as test from TEST where A in (${Prisma.join( ["1", "2"] )}); }

Expected behavior

The join function should exist on the Prisma type.

Prisma information

Dependency on "@prisma/client": "^4.8.0"

Environment & setup

This is an issue in Windows and in github workflows.

Prisma Version

8.19.2
CaseyHaralson commented 1 year ago

I should mention that the compilation works after running prisma generate. But I assume this shouldn't be necessary?

Jolg42 commented 1 year ago

Yes, running prisma generate is necessary. I think this is because $queryRaw depends on the provider. We could maybe mention something in the docs.

CaseyHaralson commented 1 year ago

Ok. I was hoping it would be possible to push the functions on to the Prisma module without a generate.

I was able to copy the join function out as a shim, and that worked, but ran into more functions that needed the generate to be run first. I ended up just running prisma generate before running my project build/unit tests. shrug

Jolg42 commented 1 year ago

For example, on MongoDB these utilities would not make sense as they are only useful when using SQL.

But I get the point that it could be nice if it would be always available without having to generate 👍🏼