following the sample on the website, I have these models defined:
type BaseModel struct {
Id string `json:"id" pg:"cuid,pk,notnull,unique" sql:"index"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at" sql:"index"`
}
type User struct {
BaseModel
Firstname *string `json:"firstname" pg:",type:VARCHAR(64)"`
Lastname *string `json:"lastname" pg:",type:VARCHAR(64)"`
Projects []*Project `json:"projects" pg:",many2many:project_users"`
Username *string `json:"username" pg:",type:VARCHAR(64)"`
Roles []*Role `json:"roles" pg:",type:VARCHAR(32)[],array"`
}
type CreateProjectInput struct {
Name string `json:"name" `
Users []*string `json:"users" `
}
and whenever I try to run the following:
func ResolveCreateProject(ctx *gin.Context, data model.CreateProjectInput) (*model.Project, error) {
var users []model.User
err := database.DB.Model(&users).
Where("cuid IN (?)", pg.In(data.Users)).
Select()
return nil, err
}
I get the following error trace:
pg: 2020/06/28 13:42:03 pool.go:317: Conn has unread data
reflect: call of reflect.Value.IsNil on string Value
goroutine 47 [running]:
runtime/debug.Stack(0x0, 0x0, 0x0)
/usr/local/Cellar/go/1.13.8/libexec/src/runtime/debug/stack.go:24 +0xa1
runtime/debug.PrintStack()
/usr/local/Cellar/go/1.13.8/libexec/src/runtime/debug/stack.go:16 +0x22
github.com/99designs/gqlgen/graphql.DefaultRecover(0x1e06900, 0xc0003aba70, 0x1bcb040, 0xc000238200, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/recovery.go:16 +0xf0
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executionContext)._Mutation_createProject.func1(0xc00034c120, 0xc00034d940, 0xc00048c628)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:1299 +0x9e
panic(0x1bcb040, 0xc000238200)
/usr/local/Cellar/go/1.13.8/libexec/src/runtime/panic.go:679 +0x1e0
reflect.Value.IsNil(0x1b861c0, 0xc00034dab0, 0x198, 0xc000509100)
/usr/local/Cellar/go/1.13.8/libexec/src/reflect/value.go:1073 +0x198
github.com/go-pg/pg/v10/types.ptrScannerFunc.func1(0x1b861c0, 0xc00034dab0, 0x198, 0x1e0ce60, 0xc0002381c0, 0xb, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/types/scan_value.go:151 +0x349
github.com/go-pg/pg/v10/types.ArrayScanner.func1(0x1b71820, 0xc0001ce488, 0x197, 0x1e0ce60, 0xc000384438, 0x31, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/types/array_scan.go:103 +0x628
github.com/go-pg/pg/v10/orm.(*Field).ScanValue(0xc0001b4280, 0x1cab000, 0xc0001ce410, 0x199, 0x1e0ce60, 0xc000384438, 0x31, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/orm/field.go:113 +0x100
github.com/go-pg/pg/v10/orm.(*structTableModel).scanColumn(0xc0003998c0, 0x7, 0xc0005090f0, 0x5, 0x1e0ce60, 0xc000384438, 0x31, 0xc0003fa200, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/orm/model_table_struct.go:278 +0x623
github.com/go-pg/pg/v10/orm.(*structTableModel).ScanColumn(0xc0003998c0, 0x7, 0xc0005090f0, 0x5, 0x1e0ce60, 0xc000384438, 0x31, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/orm/model_table_struct.go:236 +0xa4
github.com/go-pg/pg/v10.readDataRow(0x1e06880, 0xc0000c0000, 0xc0003843c0, 0x1df8ce0, 0xc0003998c0, 0xc000101080, 0xe, 0xe, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/messages.go:810 +0x3f7
github.com/go-pg/pg/v10.readSimpleQueryData(0x1e06880, 0xc0000c0000, 0xc0003843c0, 0x1cc6bc0, 0xc0003998c0, 0x0, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/messages.go:873 +0x427
github.com/go-pg/pg/v10.(*baseDB).simpleQueryData.func1(0xc0003843c0, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:621 +0xbc
github.com/go-pg/pg/v10/internal/pool.(*Conn).WithReader.func1(0x1e06880, 0xc0000c0000, 0x1e0e520, 0x23f7168, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/internal/pool/conn.go:80 +0x158
github.com/go-pg/pg/v10/internal.WithSpan(0x1e06880, 0xc0000c0000, 0x1ce789e, 0xb, 0xc00048aa10, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/internal/util.go:84 +0x2e4
github.com/go-pg/pg/v10/internal/pool.(*Conn).WithReader(0xc0003ae190, 0x1e06880, 0xc0000c0000, 0x0, 0xc00048aab8, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/internal/pool/conn.go:73 +0xbe
github.com/go-pg/pg/v10.(*baseDB).simpleQueryData(0xc0003d2000, 0x1e06880, 0xc0000c0000, 0xc0003ae190, 0x1cc6bc0, 0xc0003998c0, 0xc0003ab9b0, 0x0, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:619 +0x1ed
github.com/go-pg/pg/v10.(*baseDB).query.func1.1(0x1e06880, 0xc0000c0000, 0xc0003ae190, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:324 +0xdf
github.com/go-pg/pg/v10.(*baseDB).withConn.func1(0x1e06880, 0xc0000c0000, 0x1e0e520, 0x23f7168, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:175 +0x29e
github.com/go-pg/pg/v10/internal.WithSpan(0x1e06880, 0xc0000c0000, 0x1ce62b9, 0x9, 0xc00048ae08, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/internal/util.go:84 +0x2e4
github.com/go-pg/pg/v10.(*baseDB).withConn(0xc0003d2000, 0x1e06880, 0xc0000c0000, 0xc00048af20, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:142 +0xad
github.com/go-pg/pg/v10.(*baseDB).query.func1(0x1e06880, 0xc0000c0000, 0x1e0e520, 0x23f7168, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:323 +0x34b
github.com/go-pg/pg/v10/internal.WithSpan(0x1e06880, 0xc0000c0000, 0x1ce2056, 0x5, 0xc00048b238, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/internal/util.go:84 +0x2e4
github.com/go-pg/pg/v10.(*baseDB).query(0xc0003d2000, 0x1e06880, 0xc0000c0000, 0x1cc6bc0, 0xc0003998c0, 0x1c5a8e0, 0xc0002380a0, 0xc00034da70, 0x1, 0x1, ...)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:314 +0x559
github.com/go-pg/pg/v10.(*baseDB).QueryContext(0xc0003d2000, 0x1e06880, 0xc0000c0000, 0x1cc6bc0, 0xc0003998c0, 0x1c5a8e0, 0xc0002380a0, 0xc00034da70, 0x1, 0x1, ...)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/base.go:293 +0xde
github.com/go-pg/pg/v10/orm.(*Query).query(0xc00000c3c0, 0x1e06880, 0xc0000c0000, 0x1e0dca0, 0xc0003998c0, 0x1c5a8e0, 0xc0002380a0, 0x0, 0x0, 0x0, ...)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/orm/query.go:865 +0x4c4
github.com/go-pg/pg/v10/orm.(*Query).Select(0xc00000c3c0, 0x0, 0x0, 0x0, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/go-pg/pg/[email protected]/orm/query.go:834 +0x218
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.ResolveCreateProject(0xc0003d8270, 0xc000456134, 0xe, 0xc0000d8e18, 0x1, 0x1, 0xc00034d9b0, 0x0, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/project.go:18 +0x33f
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/resolver.(*mutationResolver).CreateProject(0xc0000d8e20, 0x1e06900, 0xc0003aba70, 0xc000456134, 0xe, 0xc0000d8e18, 0x1, 0x1, 0xc00034d9b0, 0x0, ...)
/Users/aien/Programming/Lo/apollo/apps/mission-control/resolver/schema.resolvers.go:46 +0x149
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executionContext)._Mutation_createProject.func2.1(0x1e06900, 0xc0003aba70, 0x0, 0x0, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:1321 +0x1d1
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/router.graphqlHandler.func2(0x1e06900, 0xc0003aba70, 0x0, 0x0, 0xc00032dfe0, 0xc00034d9f0, 0x1, 0x1, 0x0, 0x0, ...)
/Users/aien/Programming/Lo/apollo/apps/mission-control/router/router.go:93 +0x38b
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executionContext)._Mutation_createProject.func2.2(0x1e06900, 0xc0003aba70, 0x0, 0x0, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:1331 +0x2b6
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executionContext)._Mutation_createProject.func2(0x1e06900, 0xc0003aba70, 0x0, 0x0, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:1334 +0x194
github.com/99designs/gqlgen/graphql/handler.newExecutor.func3(0x1e06900, 0xc0003aba70, 0xc00032dfa0, 0x0, 0x0, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/executor.go:36 +0x6d
github.com/99designs/gqlgen/graphql/handler.newExecutor.func6.1(0x1e06900, 0xc0003aba70, 0x0, 0x0, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/executor.go:64 +0x94
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/router.Introspection.InterceptField(0xc0002f4340, 0x0, 0x1e06900, 0xc0003aba70, 0xc00032dfc0, 0x0, 0x0, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/router/extension.go:36 +0x84
github.com/99designs/gqlgen/graphql/handler.newExecutor.func6(0x1e06900, 0xc0003aba70, 0xc00032dfa0, 0x0, 0x0, 0x0, 0x0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/executor.go:63 +0x11c
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executionContext)._Mutation_createProject(0xc00034c120, 0x1e06900, 0xc0003aa990, 0xc0002f6780, 0xc00032c300, 0x2, 0x2, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:1318 +0x545
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executionContext)._Mutation(0xc00034c120, 0x1e06900, 0xc0003aa990, 0xc000507dc0, 0x2, 0x2, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:4531 +0xf83
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executableSchema).Exec.func2.1(0x1e06900, 0xc0003aa960, 0x0, 0x0, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:499 +0xd9
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executionContext)._mutationMiddleware(0xc00034c120, 0x1e06900, 0xc0003aa960, 0xc00015c8c0, 0xc00032c2e0, 0x0, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:881 +0x3ea
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/controller.(*executableSchema).Exec.func2(0x1e06900, 0xc0003aa960, 0x0)
/Users/aien/Programming/Lo/apollo/apps/mission-control/controller/graphql.go:498 +0x12a
github.com/99designs/gqlgen/graphql/handler.executor.DispatchOperation.func1.1.1(0x1e06900, 0xc0003aa960, 0x0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/executor.go:100 +0x67
github.com/99designs/gqlgen/graphql/handler.newExecutor.func2(0x1e06900, 0xc0003aa960, 0xc00034c130, 0x0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/executor.go:33 +0x43
github.com/99designs/gqlgen/graphql/handler.executor.DispatchOperation.func1.1(0x1e06900, 0xc0003aa960, 0x0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/executor.go:99 +0x118
github.com/99designs/gqlgen/graphql/handler/transport.POST.Do(0x33661b0, 0xc0003d8270, 0xc0002f8300, 0x1e04d80, 0xc0003d3ae0)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/transport/http_post.go:52 +0x758
github.com/99designs/gqlgen/graphql/handler.(*Server).ServeHTTP(0xc00045e000, 0x33661b0, 0xc0003d8270, 0xc0002f8300)
/Users/aien/go/pkg/mod/github.com/99designs/[email protected]/graphql/handler/server.go:140 +0x201
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/router.graphqlHandler.func4(0xc0003d8270)
/Users/aien/Programming/Lo/apollo/apps/mission-control/router/router.go:148 +0xa8
github.com/gin-gonic/gin.(*Context).Next(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:147 +0x8c
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/middleware.GinContextToContextMiddleware.func1(0xc0003d8270)
/Users/aien/Programming/Lo/apollo/apps/mission-control/middleware/gin.go:12 +0x130
github.com/gin-gonic/gin.(*Context).Next(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:147 +0x8c
riant.jetbrains.space/p/apollo/code/apollo/apps/mission-control/middleware.JsonHeaderMiddleWare(0xc0003d8270)
/Users/aien/Programming/Lo/apollo/apps/mission-control/middleware/header.go:9 +0x63
github.com/gin-gonic/gin.(*Context).Next(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:147 +0x8c
github.com/gin-gonic/gin.RecoveryWithWriter.func1(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/recovery.go:83 +0x74
github.com/gin-gonic/gin.(*Context).Next(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:147 +0x8c
github.com/toorop/gin-logrus.Logger.func1(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/toorop/[email protected]/logger.go:31 +0xcc
github.com/gin-gonic/gin.(*Context).Next(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:147 +0x8c
github.com/gin-contrib/sessions.Sessions.func1(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-contrib/[email protected]/sessions.go:52 +0x233
github.com/gin-gonic/gin.(*Context).Next(0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/context.go:147 +0x8c
github.com/gin-gonic/gin.(*Engine).handleHTTPRequest(0xc00044e000, 0xc0003d8270)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:403 +0x434
github.com/gin-gonic/gin.(*Engine).ServeHTTP(0xc00044e000, 0x1e049c0, 0xc0003cc2a0, 0xc000462000)
/Users/aien/go/pkg/mod/github.com/gin-gonic/[email protected]/gin.go:364 +0xd6
net/http.serverHandler.ServeHTTP(0xc0003cc1c0, 0x1e049c0, 0xc0003cc2a0, 0xc000462000)
/usr/local/Cellar/go/1.13.8/libexec/src/net/http/server.go:2802 +0x20f
net/http.(*conn).serve(0xc0003d0140, 0x1e06840, 0xc0002ec800)
/usr/local/Cellar/go/1.13.8/libexec/src/net/http/server.go:1890 +0x1716
created by net/http.(*Server).Serve
/usr/local/Cellar/go/1.13.8/libexec/src/net/http/server.go:2928 +0x931
If I don't use the pg.In()
then no results will return, although I'm pretty sure the user ids exist.
I will provide more details if you need.
thanks