Prisma: [Introspection] `error: Error parsing attribute '@default': Expected a constant literal value, but received functional value 'dbgenerated'.` - PostgreSQL enum defaults are wrongly introspected as `dbgenerated()`

Created on 18 Mar 2020  路  1Comment  路  Source: prisma/prisma

Only in postgresql_private/authory.log:

error: Error parsing attribute '@default': Expected a constant literal value, but received functional value 'dbgenerated'.
  -->  schema.prisma:170
   | 
169 |   source                      String?
170 |   status                      RootStatus   @default(dbgenerated())
   | 

Model + Enum:

model CrawlRoot {
  ...
  status                      RootStatus   @default(dbgenerated())
  ...
}

enum RootStatus {
  ContinousCrawlRunning
  FullCrawlAnalyzeRunning
  FullCrawlRunning
  ImportFinished
  New
}

SQL:

CREATE TABLE public."CrawlRoot" (
    ...
    status public."RootStatus" DEFAULT 'New'::public."RootStatus" NOT NULL,
    ...
);

CREATE TYPE public."RootStatus" AS ENUM (
    'FullCrawlRunning',
    'FullCrawlAnalyzeRunning',
    'ImportFinished',
    'ContinousCrawlRunning',
    'New'
);
bu2-confirmed kinbug introspection

Most helpful comment

As a quick fix we're going to adjust the validator to allow dbgenerated() since this should be valid. Correctly parsing the Enum values will take a bit longer since their formatting can differ wildly.

>All comments

As a quick fix we're going to adjust the validator to allow dbgenerated() since this should be valid. Correctly parsing the Enum values will take a bit longer since their formatting can differ wildly.

Was this page helpful?
0 / 5 - 0 ratings