Skip to content

Commit 8048762

Browse files
committed
do not remove the first field in updates
Signed-off-by: Miguel Molina <[email protected]>
1 parent 833eedb commit 8048762

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

store.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ func (s *Store) Update(schema Schema, record Record, cols ...SchemaField) (int64
228228
}
229229

230230
// remove the ID from there
231-
columnNames := ColumnNames(cols)[1:]
231+
columnNames := ColumnNames(cols)
232232
values, columnNames, err := RecordValues(record, columnNames...)
233233
if err != nil {
234234
return 0, err

store_test.go

+6
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ func (s *StoreSuite) TestUpdate() {
8888
s.Equal(int64(1), rows, "rows affected")
8989
s.assertModel(m)
9090

91+
m.Name = "c"
92+
rows, err = s.store.Update(ModelSchema, m, NewSchemaField("name"))
93+
s.NoError(err)
94+
s.Equal(int64(1), rows, "rows affected")
95+
s.assertModel(m)
96+
9197
m.setWritable(false)
9298
_, err = s.store.Update(ModelSchema, m)
9399
s.Equal(ErrNotWritable, err)

0 commit comments

Comments
 (0)