prisma / studio

🎙️ The easiest way to explore and manipulate your data in all of your Prisma projects.
https://www.prisma.io/studio
1.89k stars 47 forks source link

false positive when validating JSON field in MYSQL #1018

Open mahdiboomeri opened 2 years ago

mahdiboomeri commented 2 years ago

Bug description

In Prisma Studio, string and boolean values for JSON field are treated as invalid (with the styling), although they are valid in MySQL (no error or warning when running the queries).

How to reproduce

CREATE TABLE facts (field JSON);
INSERT INTO facts VALUES ('"test"');
INSERT INTO facts VALUES ('true');

Expected behavior

No response

Prisma information

prisma                  : 4.3.1
@prisma/client          : 4.3.1
Current platform        : debian-openssl-1.1.x
Query Engine (Node-API) : libquery-engine c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/.pnpm/@prisma+engines@4.3.1/node_modules/@prisma/engines/libquery_engine-debian-openssl-1.1.x.so.node)
Migration Engine        : migration-engine-cli c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/.pnpm/@prisma+engines@4.3.1/node_modules/@prisma/engines/migration-engine-debian-openssl-1.1.x)
Introspection Engine    : introspection-core c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/.pnpm/@prisma+engines@4.3.1/node_modules/@prisma/engines/introspection-engine-debian-openssl-1.1.x)
Format Binary           : prisma-fmt c875e43600dfe042452e0b868f7a48b817b9640b (at node_modules/.pnpm/@prisma+engines@4.3.1/node_modules/@prisma/engines/prisma-fmt-debian-openssl-1.1.x)
Format Wasm             : @prisma/prisma-fmt-wasm 4.3.0-32.c875e43600dfe042452e0b868f7a48b817b9640b
Default Engines Hash    : c875e43600dfe042452e0b868f7a48b817b9640b
Studio                  : 0.473.0
Preview Features        : referentialIntegrity

Environment & setup

Prisma logs

No response

petradonka commented 2 years ago

Could you share your Prisma schema, or the relevant part of it where the field is declared? Thanks!

mahdiboomeri commented 2 years ago
model UserMeta {
  id     Int    @id @default(autoincrement())
  User   User   @relation(fields: [userId], references: [id])
  userId String
  key    String
  value  Json

  @@unique([userId, key])
  @@index([userId])
}
await prisma.userMeta.create({
    data: {
        userId,
        key: 'isFoo',
        value: true,
    },
});

await prisma.userMeta.create({
    data: {
        userId,
        key: 'isBar',
        value: "foo",
    },
});
petradonka commented 2 years ago

Thanks for the extra info. This does indeed look like a bug, I've added it to our backlog.