-
Notifications
You must be signed in to change notification settings - Fork 8
Open
Description
Currently encodeValues() Doesn't check for pointer to struct
Doesn't work:
func encodeValues(v any, skipType string, skipZeroValues bool) map[string]SQLValuer {
t := reflect.ValueOf(v)
// if we received a map we will just convert it to a map of SQLValuer
if t.Kind() == reflect.Map {
return convertMapToSQLValuer(v.(map[string]any))
}
fields := reflect.VisibleFields(t.Type())
works:
t := reflect.ValueOf(v)
// if we received a map we will just convert it to a map of SQLValuer
if t.Kind() == reflect.Map {
return convertMapToSQLValuer(v.(map[string]any))
}
// Check if the type is a pointer
if t.Kind() == reflect.Pointer {
t = t.Elem() // Dereference to get the underlying type
}
fields := reflect.VisibleFields(t.Type())
Doesn't work:
func (c *GroupsClient) Create(ctx context.Context, i *CreateGroupInput) (*Group, error) {
g, err := gx.Insert[Group](ctx, c.p, g_iam_group.GetTable(), i, gx.WithInsertReturningAll())
if err != nil {
return nil, err
}
...
works:
func (c *GroupsClient) Create(ctx context.Context, i *CreateGroupInput) (*Group, error) {
g, err := gx.Insert[Group](ctx, c.p, g_iam_group.GetTable(), *i, gx.WithInsertReturningAll())
if err != nil {
return nil, err
}
...
Metadata
Metadata
Assignees
Labels
No labels