From 316dcd57fe713d438ebdf2d7e58ac57ace35c886 Mon Sep 17 00:00:00 2001 From: "Giau. Tran Minh" <12751435+giautm@users.noreply.github.com> Date: Sat, 7 Sep 2024 04:44:15 -0700 Subject: [PATCH] entgql: fixed zero value on `first`/`last` when receive `null` input (#601) --- entgql/internal/todo/ent/gql_collection.go | 2 +- entgql/internal/todofed/ent/gql_collection.go | 2 +- entgql/internal/todogotype/ent/gql_collection.go | 2 +- entgql/internal/todopulid/ent/gql_collection.go | 2 +- entgql/internal/todouuid/ent/gql_collection.go | 2 +- entgql/template/collection.tmpl | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/entgql/internal/todo/ent/gql_collection.go b/entgql/internal/todo/ent/gql_collection.go index ee6a0a0ae..175dea929 100644 --- a/entgql/internal/todo/ent/gql_collection.go +++ b/entgql/internal/todo/ent/gql_collection.go @@ -1663,7 +1663,7 @@ func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]a func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{firstField, lastField} { v, ok := args[k] - if !ok { + if !ok || v == nil { continue } i, err := graphql.UnmarshalInt(v) diff --git a/entgql/internal/todofed/ent/gql_collection.go b/entgql/internal/todofed/ent/gql_collection.go index b7035f8ad..abefb433f 100644 --- a/entgql/internal/todofed/ent/gql_collection.go +++ b/entgql/internal/todofed/ent/gql_collection.go @@ -315,7 +315,7 @@ func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]a func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{firstField, lastField} { v, ok := args[k] - if !ok { + if !ok || v == nil { continue } i, err := graphql.UnmarshalInt(v) diff --git a/entgql/internal/todogotype/ent/gql_collection.go b/entgql/internal/todogotype/ent/gql_collection.go index edd4ba70a..3f597984e 100644 --- a/entgql/internal/todogotype/ent/gql_collection.go +++ b/entgql/internal/todogotype/ent/gql_collection.go @@ -1230,7 +1230,7 @@ func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]a func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{firstField, lastField} { v, ok := args[k] - if !ok { + if !ok || v == nil { continue } i, err := graphql.UnmarshalInt(v) diff --git a/entgql/internal/todopulid/ent/gql_collection.go b/entgql/internal/todopulid/ent/gql_collection.go index 0080b46da..9209b9cad 100644 --- a/entgql/internal/todopulid/ent/gql_collection.go +++ b/entgql/internal/todopulid/ent/gql_collection.go @@ -1177,7 +1177,7 @@ func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]a func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{firstField, lastField} { v, ok := args[k] - if !ok { + if !ok || v == nil { continue } i, err := graphql.UnmarshalInt(v) diff --git a/entgql/internal/todouuid/ent/gql_collection.go b/entgql/internal/todouuid/ent/gql_collection.go index fd8260a92..d9c50523f 100644 --- a/entgql/internal/todouuid/ent/gql_collection.go +++ b/entgql/internal/todouuid/ent/gql_collection.go @@ -1177,7 +1177,7 @@ func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]a func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{firstField, lastField} { v, ok := args[k] - if !ok { + if !ok || v == nil { continue } i, err := graphql.UnmarshalInt(v) diff --git a/entgql/template/collection.tmpl b/entgql/template/collection.tmpl index 0ab3a3c80..5ab8691e1 100644 --- a/entgql/template/collection.tmpl +++ b/entgql/template/collection.tmpl @@ -299,7 +299,7 @@ func fieldArgs(ctx context.Context, whereInput any, path ...string) map[string]a func unmarshalArgs(ctx context.Context, whereInput any, args map[string]any) map[string]any { for _, k := range []string{firstField, lastField} { v, ok := args[k] - if !ok { + if !ok || v == nil { continue } i, err := graphql.UnmarshalInt(v)