Skip to content

Commit 869a555

Browse files
committed
rename structFieldValues to writeableStructFieldValues
1 parent 5574c61 commit 869a555

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

impl/insert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func insertStructValues(table string, rowStruct any, namer sqldb.StructFieldName
136136
return nil, nil, fmt.Errorf("InsertStruct into table %s: expected struct but got %T", table, rowStruct)
137137
}
138138

139-
columns, _, vals = structFieldValues(v, namer, ignoreColumns, restrictToColumns, false)
139+
columns, _, vals = writeableStructFieldValues(v, namer, ignoreColumns, restrictToColumns, false)
140140
if len(columns) == 0 {
141141
return nil, nil, fmt.Errorf("InsertStruct into table %s: %T has no exported struct fields with `db` tag", table, rowStruct) // TODO better error message
142142
}

impl/scanstruct.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ func getStructFieldPointers(v reflect.Value, namer sqldb.StructFieldNamer, ignor
9696
return nil
9797
}
9898

99-
// structFieldValues returns the struct field names using the passed namer ignoring names in ignoreNames
99+
// writeableStructFieldValues returns the struct field names using the passed namer ignoring names in ignoreNames
100100
// and if restrictToNames is not empty, then filtering out names not in it.
101101
// struct fields with ,readonly suffix in their struct field naming tag will not be returned
102102
// because this function is intended for getting struct values for writing.
@@ -105,7 +105,7 @@ func getStructFieldPointers(v reflect.Value, namer sqldb.StructFieldNamer, ignor
105105
// The same number of pkCol bools will be returend as names, every corresponding bool marking
106106
// if the name had the ,pk suffix in their struct field naming tag.
107107
// If false is passed for keepReadOnly then
108-
func structFieldValues(v reflect.Value, namer sqldb.StructFieldNamer, ignoreNames, restrictToNames []string, keepPK bool) (names []string, flags []sqldb.FieldFlag, vals []any) {
108+
func writeableStructFieldValues(v reflect.Value, namer sqldb.StructFieldNamer, ignoreNames, restrictToNames []string, keepPK bool) (names []string, flags []sqldb.FieldFlag, vals []any) {
109109
for i := 0; i < v.NumField(); i++ {
110110
field := v.Type().Field(i)
111111
name, flag, ok := namer.StructFieldName(field)
@@ -114,7 +114,7 @@ func structFieldValues(v reflect.Value, namer sqldb.StructFieldNamer, ignoreName
114114
}
115115

116116
if field.Anonymous {
117-
embedNames, embedFlags, embedValues := structFieldValues(v.Field(i), namer, ignoreNames, restrictToNames, keepPK)
117+
embedNames, embedFlags, embedValues := writeableStructFieldValues(v.Field(i), namer, ignoreNames, restrictToNames, keepPK)
118118
names = append(names, embedNames...)
119119
flags = append(flags, embedFlags...)
120120
vals = append(vals, embedValues...)

impl/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func UpdateStruct(conn sqldb.Connection, table string, rowStruct any, namer sqld
7676
return fmt.Errorf("UpdateStruct of table %s: expected struct but got %T", table, rowStruct)
7777
}
7878

79-
columns, flags, vals := structFieldValues(v, namer, ignoreColumns, restrictToColumns, true)
79+
columns, flags, vals := writeableStructFieldValues(v, namer, ignoreColumns, restrictToColumns, true)
8080
if len(columns) == 0 {
8181
return fmt.Errorf("UpdateStruct of table %s: %T has no exported struct fields with `db` tag", table, rowStruct) // TODO better error message
8282
}

impl/upsert.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func UpsertStruct(conn sqldb.Connection, table string, rowStruct any, namer sqld
2626
return fmt.Errorf("UpsertStruct to table %s: expected struct but got %T", table, rowStruct)
2727
}
2828

29-
columns, flags, vals := structFieldValues(v, namer, ignoreColumns, restrictToColumns, true)
29+
columns, flags, vals := writeableStructFieldValues(v, namer, ignoreColumns, restrictToColumns, true)
3030
if len(columns) == 0 {
3131
return fmt.Errorf("UpsertStruct to table %s: %T has no exported struct fields with `db` tag", table, rowStruct) // TODO better error message
3232
}

0 commit comments

Comments
 (0)