Skip to content

Commit

Permalink
do not remove the first field in updates
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
  • Loading branch information
erizocosmico committed Aug 9, 2017
1 parent 833eedb commit 8048762
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion store.go
Expand Up @@ -228,7 +228,7 @@ func (s *Store) Update(schema Schema, record Record, cols ...SchemaField) (int64
}

// remove the ID from there
columnNames := ColumnNames(cols)[1:]
columnNames := ColumnNames(cols)
values, columnNames, err := RecordValues(record, columnNames...)
if err != nil {
return 0, err
Expand Down
6 changes: 6 additions & 0 deletions store_test.go
Expand Up @@ -88,6 +88,12 @@ func (s *StoreSuite) TestUpdate() {
s.Equal(int64(1), rows, "rows affected")
s.assertModel(m)

m.Name = "c"
rows, err = s.store.Update(ModelSchema, m, NewSchemaField("name"))
s.NoError(err)
s.Equal(int64(1), rows, "rows affected")
s.assertModel(m)

m.setWritable(false)
_, err = s.store.Update(ModelSchema, m)
s.Equal(ErrNotWritable, err)
Expand Down

0 comments on commit 8048762

Please sign in to comment.