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

Enums not added to select #18335

Closed
d-sooter opened this issue Mar 15, 2023 · 7 comments
Closed

Enums not added to select #18335

d-sooter opened this issue Mar 15, 2023 · 7 comments
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: enum "type"/block `enum` topic: jsonProtocol

Comments

@d-sooter
Copy link

Bug description

When executing a findMany without specifying specific columns, my enum fields are not included in the select ( log running)

SELECT "transmuter"."Formatters"."id", "transmuter"."Formatters"."tenant", "transmuter"."Formatters"."name", "transmuter"."Formatters"."description", "transmuter"."Formatters"."script", "transmuter"."Formatters"."version", "transmuter"."Formatters"."active", "transmuter"."Formatters"."tags", "transmuter"."Formatters"."matchers", "transmuter"."Formatters"."created_at", "transmuter"."Formatters"."created_by", "transmuter"."Formatters"."updated_at", "transmuter"."Formatters"."updated_by" FROM "transmuter"."Formatters" WHERE "transmuter"."Formatters"."active" = $1 OFFSET $2

If i specify the colums in a select it works:

Query: SELECT "transmuter"."Formatters"."id", "transmuter"."Formatters"."language" FROM "transmuter"."Formatters" WHERE "transmuter"."Formatters"."active" = $1 OFFSET $2

I changed the schema to a string and the query works as expected.

How to reproduce

Expected behavior

No response

Prisma information

// Add your schema.prisma
enum Language {
    JS
    TS

    @@schema("transmuter")
}

model Formatters {
    id          Int       @id @default(autoincrement())
    tenant      String    @default("default")
    name        String
    description String
    script      String
    language    Language  @default(JS)
    version     Int       @default(1)
    active      Boolean   @default(false)
    tags        Json?
    matchers    Json
    // Managed fields
    createdAt   DateTime? @default(now()) @map("created_at")
    createdBy   String?   @map("created_by")
    updatedAt   DateTime? @updatedAt @map("updated_at")
    updatedBy   String?   @map("updated_by")

    @@schema("transmuter")
    @@unique([name, version], name: "formatters_name_version_key")
        let client = new PrismaClient({
            datasources: {
                db: {
                    url: this.configService.get('prisma.url'),
                },
            },
            errorFormat: 'pretty',
            log: this.configService.get('debug')
                ? [
                      { emit: 'event', level: 'query' },
                      { emit: 'stdout', level: 'info' },
                      { emit: 'stdout', level: 'warn' },
                      { emit: 'stdout', level: 'error' },
                  ]
                : [],
        });

Environment & setup

  • OS: Windows
  • Database: PostgreSQL
  • Node.js version: 16
  • Prisma 4.11.0

Prisma Version

prisma                  : 4.11.0
@prisma/client          : 4.11.0
Current platform        : windows
Query Engine (Node-API) : libquery-engine 8fde8fef4033376662cad983758335009d522acb (at ..\..\node_modules\.pnpm\@prisma+engines@4.11.0\node_modules\@prisma\engines\query_engine-windows.dll.node)
Migration Engine        : migration-engine-cli 8fde8fef4033376662cad983758335009d522acb (at ..\..\node_modules\.pnpm\@prisma+engines@4.11.0\node_modules\@prisma\engines\migration-engine-windows.exe)
Format Wasm             : @prisma/prisma-fmt-wasm 4.11.0-57.8fde8fef4033376662cad983758335009d522acb
Default Engines Hash    : 8fde8fef4033376662cad983758335009d522acbStudio                  : 0.483.0
Preview Features        : fullTextSearch, fullTextIndex, metrics, multiSchema, clientExtensions, views, jsonProtocol
@d-sooter d-sooter added the kind/bug A reported bug. label Mar 15, 2023
@janpio janpio added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. topic: enum "type"/block `enum` labels Mar 15, 2023
@janpio
Copy link
Member

janpio commented Mar 15, 2023

Can you share the actual findMany query you ran?

@d-sooter
Copy link
Author

Sure here is the request

return this.prisma.client.messageHandler.findMany({ where: { active: true, }, });

@ebg1223
Copy link

ebg1223 commented Mar 17, 2023

I am having the same issue!

@ebg1223
Copy link

ebg1223 commented Mar 17, 2023

After some testing, it appears this is related to enabling jsonProtocol. For my example, disabling the jsonProtocol preview feature fixed the issue. @d-sooter, maybe you can confirm?

@d-sooter
Copy link
Author

I can confirm that it works without the JsonProtocol feature

@janpio
Copy link
Member

janpio commented Mar 17, 2023

Ah, I missed that you were using the preview feature.

This should already be fixed in our development version. You can read more about it in these two issues: #18148 + #18200 If you can confirm this is fixed, please close this issue. Thanks!

@janpio
Copy link
Member

janpio commented Mar 24, 2023

ping @d-sooter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. team/client Issue for team Client. topic: enum "type"/block `enum` topic: jsonProtocol
Projects
None yet
Development

No branches or pull requests

3 participants