Skip to content

Commit

Permalink
Merge branch 'main' into feat/errors-uqv
Browse files Browse the repository at this point in the history
  • Loading branch information
steebchen authored Jan 14, 2024
2 parents c1a0040 + 9b77eb5 commit dc70b02
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 12 deletions.
4 changes: 2 additions & 2 deletions binaries/version.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package binaries

// PrismaVersion is a hardcoded version of the Prisma CLI.
const PrismaVersion = "5.7.1"
const PrismaVersion = "5.8.0"

// EngineVersion is a hardcoded version of the Prisma Engine.
// The versions can be found under https://github.com/prisma/prisma-engines/commits/main
const EngineVersion = "0ca5ccbcfa6bdc81c003cf549abe4269f59c41e5"
const EngineVersion = "0a83d8541752d7582de2ebc1ece46519ce72a848"
2 changes: 1 addition & 1 deletion docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"react-dom": "18.2.0"
},
"devDependencies": {
"@types/node": "20.10.6",
"@types/node": "20.11.0",
"next-sitemap": "4.2.3",
"typescript": "5.3.3"
}
Expand Down
8 changes: 4 additions & 4 deletions docs/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions generator/templates/_header.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ const RFC3339Milli = types.RFC3339Milli

type BatchResult = types.BatchResult

type Boolean = bool
type String = string
type Int = int
type Float = float64

type DateTime = types.DateTime
type JSON = types.JSON
type Bytes = types.Bytes
Expand Down
4 changes: 2 additions & 2 deletions generator/templates/models.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
type Relations{{ $model.Name.GoCase }} struct {
{{ range $field := $model.Fields }}
{{- if $field.Kind.IsRelation }}
{{ $field.Name.GoCase }} {{ if $field.IsList }}[]{{ else }}*{{ end }}{{ $field.Type.Value }}Model {{ $field.Name.Tag false }}
{{ $field.Name.GoCase }} {{ if $field.IsList }}[]{{ else }}*{{ end }}{{ $field.Type.GoCase }}Model {{ $field.Name.Tag false }}
{{- end -}}
{{ end }}
}
Expand All @@ -46,7 +46,7 @@
{{- range $field := $model.Fields }}
{{- if or (not $field.IsRequired) ($field.Kind.IsRelation) }}
func (r {{ $model.Name.GoCase }}Model) {{ $field.Name.GoCase }}() (
{{- if $field.IsList }}value []{{ else }}value{{ end }} {{ if and $field.Kind.IsRelation (not $field.IsList) }}*{{ end }}{{ $field.Type.Value }}{{ if $field.Kind.IsRelation }}Model{{ end -}}
{{- if $field.IsList }}value []{{ else }}value{{ end }} {{ if and $field.Kind.IsRelation (not $field.IsList) }}*{{ end }}{{ $field.Type.GoCase }}{{ if $field.Kind.IsRelation }}Model{{ end -}}
{{- if or (not $field.Kind.IsRelation) (and (not $field.IsList) (not $field.IsRequired)) -}}
, ok bool
{{- end -}}
Expand Down
6 changes: 3 additions & 3 deletions generator/templates/query.gotpl
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
}

// Set the optional value of {{ $field.Name.GoCase }} dynamically
func (r {{ $struct }}) SetIfPresent(value *{{ if $field.IsList }}[]{{ else }}{{ end }}{{ $field.Type.Value }}) {{ $setReturnStruct }} {
func (r {{ $struct }}) SetIfPresent(value *{{ if $field.IsList }}[]{{ else }}{{ end }}{{ $field.Type.GoCase }}) {{ $setReturnStruct }} {
if value == nil {
return {{ $setReturnStruct }}{}
}
Expand All @@ -276,7 +276,7 @@

{{ if and (not $field.IsRequired) (not $field.IsList) (not $field.Prisma) }}
// Set the optional value of {{ $field.Name.GoCase }} dynamically
func (r {{ $struct }}) SetOptional(value *{{ $field.Type.Value }}) {{ $setReturnStruct }} {
func (r {{ $struct }}) SetOptional(value *{{ $field.Type.GoCase }}) {{ $setReturnStruct }} {
if value == nil {
{{/* nil value of type */}}
var v *{{ $field.Type.Value }}
Expand Down Expand Up @@ -367,7 +367,7 @@
}

{{ if and (not $field.IsRequired) (not $field.Prisma) }}
func (r {{ $struct }}) EqualsOptional(value *{{ $field.Type.Value }}) {{ $returnStruct }} {
func (r {{ $struct }}) EqualsOptional(value *{{ $field.Type.GoCase }}) {{ $returnStruct }} {
return {{ $returnStruct }}{
data: builder.Field{
Name: "{{ $field.Name }}",
Expand Down
3 changes: 3 additions & 0 deletions generator/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ func TestString_GoCase(t *testing.T) {
}, {
have: "anotherIdStuffSomethingId",
want: "AnotherIDStuffSomethingID",
}, {
have: "APISession",
want: "APISession",
}}
for _, tt := range tests {
t.Run(fmt.Sprintf("%s -> %s", tt.have, tt.want), func(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions helpers/gocase/gocase_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func TestConverter_ToLower(t *testing.T) {
{conv: dc, have: "anotherIdStuffSomethingId", want: "anotherIDStuffSomethingID"},
{conv: dc, have: "anotherIdStuffSomethingId", want: "anotherIDStuffSomethingID"},
{conv: dc, have: "another_id_stuff_something_id", want: "anotherIDStuffSomethingID"},
// {conv: dc, have: "APISession", want: "apiSession"},

// {conv: cc, have: "JsonFile", want: "jsonFile"},
// {conv: cc, have: "CsvFile", want: "csvFile"},
Expand Down Expand Up @@ -90,6 +91,7 @@ func TestConverter_ToUpper(t *testing.T) {
{conv: dc, have: "anotherIdStuffSomethingId", want: "AnotherIDStuffSomethingID"},
{conv: dc, have: "anotherIdStuffSomethingId", want: "AnotherIDStuffSomethingID"},
{conv: dc, have: "another_id_stuff_something_id", want: "AnotherIDStuffSomethingID"},
{conv: dc, have: "APISession", want: "APISession"},

{conv: cc, have: "JsonFile", want: "JSONFile"},
{conv: cc, have: "CsvFile", want: "CSVFile"},
Expand Down
14 changes: 14 additions & 0 deletions test/features/composite/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,22 @@ model User {
somethingId String?
anotherIdStuff String?
apiStuff APIStuff? @relation(fields: [somethingId], references: [id])
@@id([firstName, lastName])
@@unique([firstName, middleName, lastName])
@@unique([somethingId, anotherIdStuff])
@@unique([anotherIdStuff, somethingId], name: "anotherIDStuffSomethingID")
}

// TODO put this somewhere else
model APIStuff {
id String @id @default(uuid())
somethingId String?
anotherID String?
idSome String?
IPSome String?
users User[]
}

0 comments on commit dc70b02

Please sign in to comment.