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

missing types #1090

Open
sansavision opened this issue Mar 24, 2024 · 3 comments
Open

missing types #1090

sansavision opened this issue Mar 24, 2024 · 3 comments

Comments

@sansavision
Copy link

We have a few tables for which the generated type is missing, we are using the latest version of electric-sql 0.9.6 and downgraded prisma to 4.8.1

Here is one of the affected prisma models

enum AttachmentType {
DOCUMENT
WEBSITE
IMAGE
ARTICLE
PROFILE
RESUME
PROJECT
OTHER
}

model Bibliography {
id String @id @default(cuid())
name String
url String
doiID String
abstract String?
type AttachmentType
projectID String
project Project @relation(fields: [projectID], references: [id], onDelete: Cascade)

@@Index([projectID])
}

here is the schema that is generated with debug mode when generating for the same model, note that "type" is Unsupported even though its a enum

enum AttachmentType {
DOCUMENT
WEBSITE
IMAGE
ARTICLE
PROFILE
RESUME
PROJECT
OTHER
}

model Bibliography {
id String @id
name String
url String
doiID String
abstract String?
type Unsupported("public.AttachmentType")
projectID String

@@Index([projectID])
@@Map("Bibliography")
}

here is the respective migration
CREATE TABLE "AttachmentResource" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"url" TEXT NOT NULL,
"description" TEXT,
"type" TEXT NOT NULL,
"projectActivityLogID" TEXT NOT NULL,
CONSTRAINT "AttachmentResource_pkey" PRIMARY KEY ("id")
) WITHOUT ROWID;

CREATE INDEX "AttachmentResource_projectActivityLogID_idx" ON "AttachmentResource" ("projectActivityLogID" ASC);

CREATE TABLE "Bibliography" (
"id" TEXT NOT NULL,
"name" TEXT NOT NULL,
"url" TEXT NOT NULL,
"doiID" TEXT NOT NULL,
"abstract" TEXT,
"type" TEXT NOT NULL,
"projectID" TEXT NOT NULL,
CONSTRAINT "Bibliography_pkey" PRIMARY KEY ("id")
) WITHOUT ROWID;

CREATE INDEX "Bibliography_projectID_idx" ON "Bibliography" ("projectID" ASC);

Lastly here is the content generated (src/generated)

Bibliography: {
fields: new Map([
[
"id",
"TEXT"
],
[
"name",
"TEXT"
],
[
"url",
"TEXT"
],
[
"doiID",
"TEXT"
],
[
"abstract",
"TEXT"
],
[
"projectID",
"TEXT"
]
]),
relations: [
],
modelSchema: (BibliographyCreateInputSchema as any)
.partial()
.or((BibliographyUncheckedCreateInputSchema as any).partial()),
createSchema: BibliographyCreateArgsSchema,
createManySchema: BibliographyCreateManyArgsSchema,
findUniqueSchema: BibliographyFindUniqueArgsSchema,
findSchema: BibliographyFindFirstArgsSchema,
updateSchema: BibliographyUpdateArgsSchema,
updateManySchema: BibliographyUpdateManyArgsSchema,
upsertSchema: BibliographyUpsertArgsSchema,
deleteSchema: BibliographyDeleteArgsSchema,
deleteManySchema: BibliographyDeleteManyArgsSchema
} as TableSchema<
z.infer,
Prisma.BibliographyCreateArgs['data'],
Prisma.BibliographyUpdateArgs['data'],
Prisma.BibliographyFindFirstArgs['select'],
Prisma.BibliographyFindFirstArgs['where'],
Prisma.BibliographyFindUniqueArgs['where'],
never,
Prisma.BibliographyFindFirstArgs['orderBy'],
Prisma.BibliographyScalarFieldEnum,
BibliographyGetPayload

,

Where the following was not generated

BibliographyCreateInputSchema
BibliographyUncheckedCreateInputSchema
BibliographyCreateArgsSchema
BibliographyCreateManyArgsSchema
BibliographyUpsertArgsSchema
BibliographyCreateInputSchema
BibliographyCreateArgs

whilst the rest was generated

I suspect that this has to do with the enum type, but as i understand you support user defined enums ?

Copy link

linear bot commented Mar 24, 2024

VAX-1756 missing types

@sansavision
Copy link
Author

Removed all the enums and now it generates with out errors. The question is though that the docs state the enums are somewhat supported, what kind of enums are supported, the above seems like a simple enum type?

@alco
Copy link
Member

alco commented Mar 28, 2024

Hey @sansavision. Can you share the Postgres view of the table and the enum type? I.e. the output of running \d Bilbiography and \dT AttachmentType.

It would also be helpful to see the contents of the electric.schema table. You can save its dump into a file with

\copy (select * from electric.schema) to schema.csv with csv

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants