-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Using citext
fields with neon database driver causes conversion error
#21807
Labels
bug/2-confirmed
Bug has been reproduced and confirmed.
kind/bug
A reported bug.
team/client
Issue for team Client.
topic: @db.Citext
Native type `Citext`
topic: driverAdapters
topic: preview 👁
topic: previewFeatures
Issue touches on an preview feature flag
Milestone
Comments
janpio
added
topic: @db.Citext
Native type `Citext`
topic: driverAdapters
bug/1-unconfirmed
Bug should have enough information for reproduction, but confirmation has not happened yet.
team/client
Issue for team Client.
labels
Nov 6, 2023
Jolg42
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
Nov 7, 2023
I could reproduce in 5.5.2 (and also in I had to do a create operation to reproduce this. Note: I also tried without driverAdapters and it worked as expected.
using import { PrismaClient } from "@prisma/client";
import { Pool, neonConfig } from "@neondatabase/serverless";
import { PrismaNeon } from "@prisma/adapter-neon";
import ws from "ws";
neonConfig.webSocketConstructor = ws;
const connectionString = `postgres://user:password@ep-something-pooler.eu-central-1.aws.neon.tech/mydb`;
async function main() {
const pool = new Pool({ connectionString });
const adapter = new PrismaNeon(pool);
const prisma = new PrismaClient({ adapter });
await prisma.someModel.deleteMany({
where: {
slug: {
equals: "someslug",
},
},
});
// Errors here
// Error converting field "slug" of expected non-nullable type "String", found incompatible value of "someslug".
const create = await prisma.someModel.create({
data: {
slug: "someslug",
},
});
console.debug({ create });
const findMany = await prisma.someModel.findMany({
where: {
slug: {
equals: "someslug",
},
},
select: {
id: true,
slug: true,
},
});
console.debug({ findMany });
prisma.$disconnect();
}
main(); |
aqrln
added a commit
that referenced
this issue
Dec 8, 2023
Treat all custom Postgres types as text in the result set. This is an alternative to #21918. Thanks to driver adapters using Postgres text protocol, unlike our native driver that uses the binary protocol, we can get away with treating all unknown extension types as text if we want to expose them to users as such — we (or the driver) don't need to know how to decode them and convert to strings if they are already strings in the first place. However, we cannot distinguish between known types added by extensions and enums without querying the catalog for type names. This may look like a problem at first, but in reality we can get away with treating enums as text in result set too, the response IR layer in the query engine uses the query schema to know it's an enum, not the type hint that comes from `quaint::Value`/`PrismaValue`. If the output type in the query schema says it's an enum, it will treat `PrismaValue::String` and `PrismaValue::Enum` equally: https://github.com/prisma/prisma-engines/blob/12d71c4263690f3990d590fbff611b2a24ef2dbc/query-engine/core/src/response_ir/internal.rs#L813. So mapping Postgres enums to `quaint::ValueType::Text` is fine, and is already supported by QE. Engines test suite passing: prisma/prisma-engines#4531 Fixes: #21807 Closes: #21918 Co-authored-by: Joël Galeran <Jolg42@users.noreply.github.com>
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: @db.Citext
Native type `Citext`
topic: driverAdapters
topic: preview 👁
topic: previewFeatures
Issue touches on an preview feature flag
Bug description
Using the postgres extension
Citext
on a field causes the error:How to reproduce
Some debug logs:
Expected behavior
Prisma should correctly convert Citext fields to strings
Prisma information
Environment & setup
Prisma Version
The text was updated successfully, but these errors were encountered: