question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When converting the following datamodel:

type A {
  id: ID! @unique

  text: String!

  meta: JSON!
}

Using the following method:

cat datamodel.graphql | prisma2 convert > schema.prisma

I get the following schema:

model A {
  id   String @default(cuid()) @id @unique
  text String
}

As we can see, the meta: JSON attribute is missing

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:27
  • Comments:30 (9 by maintainers)

github_iconTop GitHub Comments

38reactions
mavileincommented, May 4, 2020

Here is a summary of what we implemented so far:

Prisma Schema The data type for JSON is called Json in the schema. It can be used like this:

model Blog {
  id   Int @id
  json Json 
}

It is supported by the MySQL and Postgres connectors. It is not supported by SQLite.

Introspection The prisma introspect command maps the following column types to Json:

  • Postgres: json and jsonb
  • MySQL: JSON

Migrations prisma migrate uses the following data type when creating a column for a field of type Json:

  • Postgres: jsonb
  • MySQL: JSON

Prisma Client A field of type Json are exposed as proper objects in Javascript.

Important Details JSON support for MySQL is only supported for versions greater than 5.6. As we don’t have version information available during schema validation no error is shown in this case. However we have version information available in prisma migrate. Therefore we error when a migration against MySQL 5.6 uses the Json data type.

35reactions
namesphillcommented, Jan 20, 2020

Hey! Do you guys happen to have an ETA on this feature?

Read more comments on GitHub >

github_iconTop Results From Across the Web

JSON Data Types - W3Schools
Valid Data Types. In JSON, values must be one of the following data types: a string; a number; an object (JSON object); an...
Read more >
JSON - DataTypes - Tutorialspoint
JSON - DataTypes, JSON format supports the following data types −
Read more >
MySQL 8.0 Reference Manual :: 11.5 The JSON Data Type
MySQL supports a native JSON data type defined by RFC 7159 that enables efficient access to data in JSON (JavaScript Object Notation) documents....
Read more >
JSON Data Types - REST
At the granular level, JSON consists of 6 data types. The first four data types (string, number, boolean and null) can be referred...
Read more >
Documentation: 15: 8.14. JSON Types - PostgreSQL
JSON data types are for storing JSON (JavaScript Object Notation) data, as specified in RFC 7159. Such data can also be stored as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found