zenstack icon indicating copy to clipboard operation
zenstack copied to clipboard

Adding `@ignore` removes types (m-n relation) from the Kysely index file.

Open AliNectar opened this issue 7 months ago • 5 comments

Description and expected behavior Adding the @ignore on a particular field should ignore that particular field only. But upon adding this various m-n relation types in the Kysely index file are removed upon running the npx zenstack generate codegen command.

Screenshots

Environment (please complete the following information):

  • ZenStack version: 2.9.1
  • Prisma version: 6.5.0
  • Database type: Postgresql (supabase)

Additional Context Note that only the types are affected. The actual tables are not affected.

AliNectar avatar May 20 '25 04:05 AliNectar

Hi @AliNectar , how is Kysely involved here? Are you using a prisma kysely generator?

ymc9 avatar May 20 '25 18:05 ymc9

@ymc9 correct. part of the config:

generator client {
  provider = "prisma-client-js"
  previewFeatures = ["postgresqlExtensions","tracing"]
  binaryTargets = ["darwin-arm64", "rhel-openssl-3.0.x", "debian-openssl-1.1.x", "debian-openssl-3.0.x", "darwin", "linux-arm64-openssl-3.0.x"]
}

generator kysely {
  provider = "prisma-kysely"

  // Optionally provide a destination directory for the generated file
  // and a filename of your choice
  output = "../kysely"
  fileName = "index.ts"
  // Optionally generate runtime enums to a separate file
  //  enumFileName = "enums.ts"
}

datasource db {
  provider   = "postgresql"
  url        = env("DATABASE_URL")
  directUrl  = env("DIRECT_URL")
  extensions = [vector, uuid_ossp(map: "uuid-ossp", schema: "extensions")]
}

AliNectar avatar May 21 '25 16:05 AliNectar

Have you checked if the generated Prisma schema is correct? The Kysely generator is run by the standard Prisma generate command.

ymc9 avatar May 21 '25 17:05 ymc9

There were no changes in the generated Prisma schema file. (only the expected change of adding @ignore). But note that we use supabase. And supabase implicitly creates tables for many to many relations and so these tables are not present in the schema file itself (.zmodel or prisma file). But the codegen step for Kysely correctly outputs the types for these many to many relations normally.

AliNectar avatar May 22 '25 00:05 AliNectar

There were no changes in the generated Prisma schema file. (only the expected change of adding @ignore). But note that we use supabase. And supabase implicitly creates tables for many to many relations and so these tables are not present in the schema file itself (.zmodel or prisma file). But the codegen step for Kysely correctly outputs the types for these many to many relations normally.

If you use supabase as a standard postgres, database schema is managed by Prisma. Prisma has native support for implicit many-to-many relations and it creates the underlying tables for you during migration.

Have you checked if the prisma schema generated by zenstack is correct? If so, have you tried running prisma generate directly and see if it works? @AliNectar

ymc9 avatar May 30 '25 05:05 ymc9