language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Language Server does not respect prisma version in monorepo

Open hrueger opened this issue 2 years ago • 4 comments

Bug description

Hi, I just broke my production application because I trusted what the VSCode Prisma Language Server (from the official extension) suggested: I removed previewFeatures = ["filteredRelationCount"] from the generator block of the schema.prisma file.

However, it turns out that I hadn't yet updated the prisma version in the package.json files in the separate packages of my monorepo. Therefore, it is acually still needed for that (older) version of prisma.

How to reproduce

  1. Create a monorepo with the prisma folder (and the schema file) at the root and a package in /packages/app1...
  2. Install an older version of prisma there
  3. Install the official prisma vscode extension
  4. See it not respect the currently installed version of prisma in the project

Expected behavior

Maybe the Plugin / Language Server could detect the prisma version from node_modules or ask? The current behaviour is a bit confusing ;-)

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["filteredRelationCount"]
}
// some query using filteredRelationCount

Environment & setup

  • OS: Windows 10
  • Database: n/a
  • Node.js version: 18.10.0

Prisma Version

Environment variables loaded from .env
prisma                  : 4.15.0
@prisma/client          : 4.15.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 8fbc245156db7124f997f4cecdd8d1219e360944 (at node_modules\@prisma\engines\query_engine-windows.dll.node)    
Migration Engine        : migration-engine-cli 8fbc245156db7124f997f4cecdd8d1219e360944 (at node_modules\@prisma\engines\migration-engine-windows.exe)
Format Wasm             : @prisma/prisma-fmt-wasm 4.15.0-28.8fbc245156db7124f997f4cecdd8d1219e360944
Default Engines Hash    : 8fbc245156db7124f997f4cecdd8d1219e360944
Studio                  : 0.484.0
Preview Features        : filteredRelationCount
┌─────────────────────────────────────────────────────────┐
│  Update available 4.15.0 -> 5.0.0                       │
│                                                         │
│  This is a major update - please follow the guide at    │
│  https://pris.ly/d/major-version-upgrade                │
│                                                         │
│  Run the following to update                            │
│    npm i --save-dev prisma@latest                       │
│    npm i @prisma/client@latest                          │
└─────────────────────────────────────────────────────────┘

hrueger avatar Jul 12 '23 15:07 hrueger

Our VSCode extension currently unfortunately does not react to the version of your project, but is fully controlled by the version of the extension you have installed in VS Code.

This is a related issue: https://github.com/prisma/language-tools/issues/66 (prisma-fmt is what is responsible for a lot of the logic, but might not actually cover the problem you encountered - not 100% sure)

janpio avatar Jul 12 '23 17:07 janpio

@hrueger What you can do for now is to select the version in VS Code UI, see screenshots: Screenshot 2023-07-12 at 19 21 42 Screenshot 2023-07-12 at 19 21 57 In extensions, select "Prisma", then "Install Another Version...", select your Prisma version.

Jolg42 avatar Jul 12 '23 17:07 Jolg42

Thanks for the tip. It's not a very important issue for me, I'll update to prisma 5 very soon anyway. However, I thought I'd just open that issue here, because I was very confused at first. Maybe we can just leave that open?

hrueger avatar Jul 13 '23 05:07 hrueger

Good news :) Sure, I also think it's worth keeping this open, you're probably not the only person who could benefit from an improvement here.

Jolg42 avatar Jul 13 '23 07:07 Jolg42