Skip to content

Commit

Permalink
fix: dont allow where conditions to be nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Bull committed Aug 24, 2023
1 parent 5663a4e commit 054573f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions node/codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,13 @@ func writeWhereConditionsInterface(w *codegen.Writer, model *proto.Model) {
w.Write(": ")
if field.Type.Type == proto.Type_TYPE_MODEL {
// Embed related models where conditions
w.Writef("%sWhereConditions | null;", field.Type.ModelName.Value)
w.Writef("%sWhereConditions", field.Type.ModelName.Value)
} else {
w.Write(toTypeScriptType(field.Type, false))
w.Write(" | ")
w.Write(toWhereConditionType(field))
w.Write(" | null;")
}
w.Write(";")

w.Writeln("")
}
Expand Down
18 changes: 9 additions & 9 deletions node/codegen_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ export interface PostCreateValues {
func TestWriteWhereConditionsInterface(t *testing.T) {
expected := `
export interface PersonWhereConditions {
firstName?: string | runtime.StringWhereCondition | null;
lastName?: string | runtime.StringWhereCondition | null;
age?: number | runtime.NumberWhereCondition | null;
dateOfBirth?: Date | runtime.DateWhereCondition | null;
gender?: Gender | GenderWhereCondition | null;
hasChildren?: boolean | runtime.BooleanWhereCondition | null;
id?: string | runtime.IDWhereCondition | null;
createdAt?: Date | runtime.DateWhereCondition | null;
updatedAt?: Date | runtime.DateWhereCondition | null;
firstName?: string | runtime.StringWhereCondition;
lastName?: string | runtime.StringWhereCondition;
age?: number | runtime.NumberWhereCondition;
dateOfBirth?: Date | runtime.DateWhereCondition;
gender?: Gender | GenderWhereCondition;
hasChildren?: boolean | runtime.BooleanWhereCondition;
id?: string | runtime.IDWhereCondition;
createdAt?: Date | runtime.DateWhereCondition;
updatedAt?: Date | runtime.DateWhereCondition;
}`
runWriterTest(t, testSchema, expected, func(s *proto.Schema, w *codegen.Writer) {
m := proto.FindModel(s.Models, "Person")
Expand Down

0 comments on commit 054573f

Please sign in to comment.