Fix some comments so the linter stops complaining

pull/2/head
Vinícius Garcia 2021-01-21 16:10:14 -03:00
parent f9a6372b8a
commit f655576bb3
3 changed files with 21 additions and 1 deletions

View File

@ -9,12 +9,14 @@ import (
"github.com/vingarcia/kissorm/nullable"
)
// User ...
type User struct {
ID int `kissorm:"id"`
Name string `kissorm:"name"`
Age int `kissorm:"age"`
}
// PartialUpdateUser ...
type PartialUpdateUser struct {
ID int `kissorm:"id"`
Name *string `kissorm:"name"`

View File

@ -4,6 +4,7 @@ import "context"
var _ ORMProvider = MockORMProvider{}
// MockORMProvider ...
type MockORMProvider struct {
InsertFn func(ctx context.Context, records ...interface{}) error
DeleteFn func(ctx context.Context, ids ...interface{}) error
@ -17,34 +18,42 @@ type MockORMProvider struct {
TransactionFn func(ctx context.Context, fn func(db ORMProvider) error) error
}
// Insert ...
func (m MockORMProvider) Insert(ctx context.Context, records ...interface{}) error {
return m.InsertFn(ctx, records...)
}
// Delete ...
func (m MockORMProvider) Delete(ctx context.Context, ids ...interface{}) error {
return m.DeleteFn(ctx, ids...)
}
// Update ...
func (m MockORMProvider) Update(ctx context.Context, records ...interface{}) error {
return m.UpdateFn(ctx, records...)
}
// Query ...
func (m MockORMProvider) Query(ctx context.Context, records interface{}, query string, params ...interface{}) error {
return m.QueryFn(ctx, records, query, params...)
}
// QueryOne ...
func (m MockORMProvider) QueryOne(ctx context.Context, record interface{}, query string, params ...interface{}) error {
return m.QueryOneFn(ctx, record, query, params...)
}
// QueryChunks ...
func (m MockORMProvider) QueryChunks(ctx context.Context, parser ChunkParser) error {
return m.QueryChunksFn(ctx, parser)
}
// Exec ...
func (m MockORMProvider) Exec(ctx context.Context, query string, params ...interface{}) error {
return m.ExecFn(ctx, query, params...)
}
// Transaction ...
func (m MockORMProvider) Transaction(ctx context.Context, fn func(db ORMProvider) error) error {
return m.TransactionFn(ctx, fn)
}

View File

@ -103,7 +103,7 @@ func FillStructWith(record interface{}, dbRow map[string]interface{}) error {
return nil
}
// This type was created to make it easier
// PtrConverter was created to make it easier
// to handle conversion between ptr and non ptr types, e.g.:
//
// - *type to *type
@ -117,6 +117,13 @@ type PtrConverter struct {
ElemValue reflect.Value
}
// NewPtrConverter instantiates a PtrConverter from
// an empty interface.
//
// The input argument can be of any type, but
// if it is a pointer then its Elem() will be
// used as source value for the PtrConverter.Convert()
// method.
func NewPtrConverter(v interface{}) PtrConverter {
if v == nil {
// This is necessary so that reflect.ValueOf
@ -141,6 +148,8 @@ func NewPtrConverter(v interface{}) PtrConverter {
}
}
// Convert attempts to convert the ElemValue to the destType received
// as argument and then returns the converted reflect.Value or an error
func (p PtrConverter) Convert(destType reflect.Type) (reflect.Value, error) {
destElemType := destType
if destType.Kind() == reflect.Ptr {