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

jsonProtocol doesn't query enum fields by default #18148

Closed
n3oney opened this issue Mar 1, 2023 · 8 comments · Fixed by prisma/prisma-engines#3758
Closed

jsonProtocol doesn't query enum fields by default #18148

n3oney opened this issue Mar 1, 2023 · 8 comments · Fixed by prisma/prisma-engines#3758
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: jsonProtocol topic: previewFeatures Issue touches on an preview feature flag
Milestone

Comments

@n3oney
Copy link

n3oney commented Mar 1, 2023

Bug description

When querying a table that has an enum field with the jsonProtocol #18095 feature enabled, the data won't include the enum field by default.

How to reproduce

  1. Enable the jsonProtocol preview feature
  2. Query some table await prisma.db.tableName.findMany();

Expected behavior

The returned data will be the same as without the jsonProtocol feature

With jsonProtocol

const products = await prisma.db.productInfo.findMany();

/*
{
  "id": "01002ac5-0098-443f-84ac-3294b3169aae",
  "name": "Product one",
  "description": "Product number one",
}
*/

Without jsonProtocol

const products = await prisma.db.productInfo.findMany();

/*
{
  "id": "01002ac5-0098-443f-84ac-3294b3169aae",
  "name": "Product one",
  "status": "Enabled",
  "description": "Product number one",
}
*/

Adding a select to the query and explicitly telling it to select that field seems to fix it.

With jsonProtocol

const products = await prisma.db.productInfo.findMany({
      select: {
        status: true,
        id: true,
        name: true,
        description: true
      }
});


/*
{
  "id": "01002ac5-0098-443f-84ac-3294b3169aae",
  "name": "Product one",
  "status": "Enabled",
  "description": "Product number one",
}
*/

Prisma information

generator client {
  provider        = "prisma-client-js"
  previewFeatures = ["jsonProtocol"]
}

datasource db {
  provider = "cockroachdb"
  url      = env("DATABASE_URL")
}

model ProductInfo {
  id                String             @id(map: "primary") @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  status            Status
  name              String
  description       String

  @@map("product_info")
}

enum Status {
  Enabled
  Disabled
  Hidden

  @@map("status")
}

Environment & setup

  • OS: Arch Linux
  • Database: CockroachDB, with Data Proxy
  • Node.js version: v19.7.0

Prisma Version

4.11.0
@n3oney n3oney added the kind/bug A reported bug. label Mar 1, 2023
@janpio janpio added topic: previewFeatures Issue touches on an preview feature flag topic: jsonProtocol bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. team/client Issue for team Client. labels Mar 1, 2023
@revmischa
Copy link

Confirmed this is happening for me after upgrading from 4.10.1 to 4.11.0

@SevInf SevInf added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. labels Mar 1, 2023
SevInf added a commit that referenced this issue Mar 1, 2023
Should help to prevent issues like #18148
@janpio janpio added this to the 4.12.0 milestone Mar 1, 2023
@revmischa
Copy link

Thanks for fixing this quickly! I would really love to be able to try out the rest of 4.11 so if there is any way you can release a patch version with this fix that would be quite nice

@janpio
Copy link
Member

janpio commented Mar 2, 2023

A patch is quite a big deal in what it signals to all our users, so a bug in a preview feature would not qualify for that.

But via this PR #18165 it will be available in prisma@dev soon, which right now has pretty much no other differences to 4.11. So if you pin that specific version that will include #18165 you should have pretty much the same as a patch and can safely test.

PS: I am pretty sure you will love the results :D

@janpio
Copy link
Member

janpio commented Mar 2, 2023

Update: prisma@4.12.0-dev.4 is out and should include the fix for this issue. Make sure to also insteall the equivalent @prisma/client@4.12.0-dev.4

SevInf added a commit that referenced this issue Mar 2, 2023
Should help to prevent issues like #18148
@veiico
Copy link

veiico commented Mar 13, 2023

Short notice just in case:
Tried using the newest 4.12.0-dev.8 version - didn't work (same as with 4.11.0).
But rolling back dev version to mentioned 4.12.0-dev.4 or 4.12.0-dev.6 - works.
Could be that the mentioned fix has been overwritten / discarded with new changes. Worth keeping this in mind.

SevInf added a commit that referenced this issue Mar 14, 2023
Should help to prevent issues like #18148
@SevInf
Copy link
Contributor

SevInf commented Mar 14, 2023

prisma@4.12.0-dev.9 contains fix for enum lists as well.
@veiico I can't reproduce the issue with dev.8 - for me it works. Could you try with dev.9.

@SevInf
Copy link
Contributor

SevInf commented Mar 15, 2023

@revmischa @veiico Could I see you prisma --version output? I am struggling to reproduce it locally. Also, couple of follow up question:

  • Did you re-run prisma generate after updating to dev.9?
  • Are you using DataProxy or normal prisma distribution?

@revmischa
Copy link

revmischa commented Mar 15, 2023

@revmischa @veiico Could I see you prisma --version output? I am struggling to reproduce it locally. Also, couple of follow up question:

prisma                  : 4.12.0-dev.9
@prisma/client          : 4.12.0-dev.9
Current platform        : debian-openssl-3.0.x
Query Engine (Node-API) : libquery-engine da9cbf177f656f6a0002c6749f5f689a1e3cc9e4 (at ../node_modules/.pnpm/@prisma+engines@4.12.0-dev.9/node_modules/@prisma/engines/libquery_engine-debian-openssl-3.0.x.so.node)
Migration Engine        : migration-engine-cli da9cbf177f656f6a0002c6749f5f689a1e3cc9e4 (at ../node_modules/.pnpm/@prisma+engines@4.12.0-dev.9/node_modules/@prisma/engines/migration-engine-debian-openssl-3.0.x)
Format Wasm             : @prisma/prisma-fmt-wasm 4.12.0-14.da9cbf177f656f6a0002c6749f5f689a1e3cc9e4
Default Engines Hash    : da9cbf177f656f6a0002c6749f5f689a1e3cc9e4
Studio                  : 0.483.0
Preview Features        : fullTextSearch, orderByNulls, jsonProtocol
  • Did you re-run prisma generate after updating to dev.9?

Yes

  • Are you using DataProxy or normal prisma distribution?

Not using DataProxy

SevInf added a commit that referenced this issue May 4, 2023
* test(client): Test default selection contents

Should help to prevent issues like #18148

* Add case for enum lists
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. topic: jsonProtocol topic: previewFeatures Issue touches on an preview feature flag
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants