Skip to content
This repository has been archived by the owner on Oct 21, 2020. It is now read-only.

Custom Types #173

Closed
mavilein opened this issue Sep 26, 2019 · 1 comment
Closed

Custom Types #173

mavilein opened this issue Sep 26, 2019 · 1 comment
Labels
area/schema engineering/blocked This open issue is blocking work in Engineering keep kind/spec Something about an actual spec (file) spec/clarify An existing spec should be clarified

Comments

@mavilein
Copy link
Contributor

mavilein commented Sep 26, 2019

The schema spec contains various statements about custom types aka type definitions. We need clarification on which parts of the spec are confirmed and should be implemented. We need this in order to start work on this epic.

Here are a few questions that come to my mind.

  1. Should we implement support for custom complex types from the get go? This would increase the scope significantly. This would require embeds to be implemented before that. E.g.:
embed Point3D {
  X Int
  Y Int
  Z Int
  @@pg.Point
  @@ms.Point
}
  1. Do we need to support @raw?
  2. In the spec i can see two kinds of ways to define custom types for a field: text String @pg.citext vs. text pg.Citext. I think we lean to the first option but we need confirmation.
  3. Some types use named arguments like pg.Varchar(n: 42). Have we settled on this syntax? @pg.varchar(23) was discussed also quite often.
@janpio janpio added area/schema engineering/blocked This open issue is blocking work in Engineering kind/spec Something about an actual spec (file) spec/clarify An existing spec should be clarified labels Sep 27, 2019
@matthewmueller
Copy link
Contributor

matthewmueller commented Oct 2, 2019

  1. Should we implement support for custom complex types from the get go?

I'd be totally find dropping this until after GA

  1. Do we need to support @raw?

The @raw is (most likely) generated on demand by the connector when you click on the "Jump to Definition" of @pg.Money. It's mean to serve as the "bottom-layer".

@sorenbs @schickling do we want to allow folks to use this in their schema.prisma files? I'm leaning towards allowing it.

  1. In the spec i can see two kinds of ways to define custom types for a field: text String @pg.citext vs. text pg.Citext. I think we lean to the first option but we need confirmation.

I don't think there's consensus on this yet. I'm currently leaning towards: https://github.com/prisma/specs/tree/master/schema#type-definitions-provided-by-connectors

Connectors provide custom types, you can use them in your schema.prisma as:

datasource pg {
  provider = "postgresql"
  url = "..."
}

model User {
  description pg.Varchar(100)
}

We replace @pg.Citext with @raw("citext") at the bottom-layer.

  1. Some types use named arguments like pg.Varchar(n: 42). Have we settled on this syntax? @pg.varchar(23) was discussed also quite often.

This should follow the same rules as arguments: https://github.com/prisma/specs/tree/master/schema#attributes

If there is only 1 argument, the key can be omitted, otherwise you need to include the key.


Let's try and finalize and I'll update the spec

/cc @sorenbs @schickling

@janpio janpio changed the title Spec needed: Custom Types Custom Types Nov 27, 2019
@janpio janpio added the keep label Sep 12, 2020
@janpio janpio closed this as completed Oct 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/schema engineering/blocked This open issue is blocking work in Engineering keep kind/spec Something about an actual spec (file) spec/clarify An existing spec should be clarified
Projects
None yet
Development

No branches or pull requests

3 participants