chrishoermann / zod-prisma-types

Generator creates zod types for your prisma models with advanced validation
Other
662 stars 50 forks source link

[BUG] useMultipleFiles results in ENAMETOOLONG with large compound ids #233

Open mmagyar opened 10 months ago

mmagyar commented 10 months ago

Describe the bug has to useMultipleFiles(*see below) and the generation fails on tables that have a large compound id. This happens since it tries to put all the compound id field names into the file name.

Truncating would work in my case, but might not be the best options, having this type colocate the same file as the table definition would be a good solution IMO, or just change the naming scheme to something like (noting only the order of if) stats_impression_aggFirstCompoundUniqueInputSchema.ts

Screenshots If applicable, add screenshots to help explain your problem.

Package versions (please complete the following information):

Additional context Prisma model:

model stats_impression_agg {
  created_at         DateTime @default(now()) @db.Timestamptz(3)
  property_id        Int
  campaign_id        Int
  ad_id              Int
  publisher_id       Int
  site_id            Int
  geo_continent_code String   @db.VarChar(10)
  geo_continent_name String   @db.VarChar(100)
  geo_country_code   String   @db.VarChar(10)
  geo_country_name   String   @db.VarChar(100)
  geo_region_code    String   @db.VarChar(10)
  geo_region_name    String   @db.VarChar(100)
  user_agent_type    String   @db.VarChar(100)
  user_agent_family  String   @db.VarChar(100)
  os_family          String   @db.VarChar(100)
  location_host      String   @db.VarChar(100)
  count              Int

  @@id([created_at, property_id, campaign_id, ad_id, publisher_id, site_id, geo_continent_code, geo_continent_name, geo_country_code, geo_country_name, geo_region_code, geo_region_name, user_agent_type, user_agent_family, os_family, location_host])
  @@index([created_at])
}

Actual error:

NAMETOOLONG: name too long, open '/Users/mmagyar/code/fusedeck/libs/prisma/prisma/generated/zod/inputTypeSchemas/stats_impression_aggCreated_atProperty_idCampaign_idAd_idPublisher_idSite_idGeo_continent_codeGeo_continent_nameGeo_country_codeGeo_country_nameGeo_region_codeGeo_region_nameUser_agent_typeUser_agent_familyOs_familyLocation_hostCompoundUniqueInputSchema.ts'

Os: MacOs 14.2