zenstack icon indicating copy to clipboard operation
zenstack copied to clipboard

false error on @relation in vscode extension when using multiple schemas

Open tmax22 opened this issue 10 months ago • 5 comments

Description and expected behavior

false error values of "references" and "fields" must have the same type, when the type actually the same and zenstack generate creates correct schema. this is an issue with vscode+intelij extensions.

image

// /zmodel/base.zmodel

import "../schema"

abstract model Base {
    id String @id @default(uuid())
    createdAt DateTime @default(now())
    updatedAt DateTime @updatedAt()

    // require login
    @@deny('all', auth() == null)

    // allow all operations for admin
    @@allow('all', auth().role.name == 'Admin')
}

model User extends Base {
    name String
    email String @unique
    profilePic String
    role Role @relation(fields: [roleId], references: [id])
    roleId String
    serviceResearches Service2Researcher[]

    @@allow('read', true)
}

model Role extends Base {
    name String @unique
    users User[]

    @@allow('read', true)
}

// /schema.zmodel

import "zmodel/base"

model Demo extends Base {
    stages DemoStage[] @relation("stages")
}


model DemoStage extends Base {
    owned_stages Demo? @relation("stages", fields: [demoId], references: [id])
    demoId String?
}

same on base by the way

image

Environment (please complete the following information):

  • ZenStack version: 1.12.3
  • Prisma version: 5.11.0
  • Database type: Postgresql

update: this bug is only in vscode, but not in intelij

tmax22 avatar Apr 14 '24 13:04 tmax22

Hi @tmax22 , which version of VSCode extension are you using? I tried both the latest and the prerelease one but couldn't reproduce it.

ymc9 avatar Apr 15 '24 07:04 ymc9

Version: 1.88.1 Commit: e170252f762678dec6ca2cc69aba1570769a5d39 Date: 2024-04-10T17:34:12.840Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Linux x64 5.15.150.1-microsoft-standard-WSL2 snap

tmax22 avatar Apr 15 '24 08:04 tmax22

I'm not sure what happened, but now vscode error has gone, but the same error appears on Webstorm now 🙃

tmax22 avatar Apr 16 '24 12:04 tmax22

I'm not sure what happened, but now vscode error has gone, but the same error appears on Webstorm now 🙃

Are you using the V2 prerelease version of VSCode extension? It might be an issue fixed in the v2 release but there isn't a version for it for webstorm yet.

ymc9 avatar Apr 16 '24 13:04 ymc9

nope. im on the normal stable release vscode extension. I'm not sure what's going on and why this happens only sometimes

tmax22 avatar Apr 16 '24 13:04 tmax22

I'm closing it for now. Please reopen if it happens again.

ymc9 avatar May 05 '24 10:05 ymc9