Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mmagyar opened this issue Jan 4, 2024 · 0 comments
Open
Assignees
Labels
bug (unconfirmed) Could be a bug

Comments

@mmagyar
Copy link

mmagyar commented Jan 4, 2024

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

  • tsc crashes when everything is in a single file, migrating a large existing database and zod-prisma-types creates a 100000+ line typescript file

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

Package versions (please complete the following information):

  • zod: 3.21.1
  • prisma: 5.6.0
  • zod-prisma-types: 3.1.6

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (unconfirmed) Could be a bug
Projects
None yet
Development

No branches or pull requests

2 participants