Skip to content

Commit

Permalink
Merge pull request gocassa#84 from b2aio/fixmapset
Browse files Browse the repository at this point in the history
Update map, rather than replacing
  • Loading branch information
crufter committed Mar 27, 2015
2 parents 5954f4a + 740767a commit 1fc20d5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion modifiers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (m Modifier) cql(name string) (string, []interface{}) {
str = fmt.Sprintf("%v = %v - [%v]", name, name, printElem(m.args[0]))
case modifierMapSetFields:
buf := new(bytes.Buffer)
buf.WriteString(fmt.Sprintf("%v = ", name))
buf.WriteString(fmt.Sprintf("%v = %v + ", name, name))
ma, ok := m.args[0].(map[string]interface{})
if !ok {
panic(fmt.Sprintf("Argument for MapSetFields is not a map: %v", m.args[0]))
Expand Down
9 changes: 6 additions & 3 deletions query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,13 @@ func TestMaps(t *testing.T) {
})).Run(); err != nil {
t.Fatal(err)
}
if err := tbl.Read("1", &c).Run(); err != nil {

// Read back into a new struct (see #83)
var c2 CustomerWithMap
if err := tbl.Read("1", &c2).Run(); err != nil {
t.Fatal(err)
}
if !reflect.DeepEqual(c, CustomerWithMap{
if !reflect.DeepEqual(c2, CustomerWithMap{
Id: "1",
Map: map[string]string{
"2": "Two",
Expand All @@ -362,7 +365,7 @@ func TestMaps(t *testing.T) {
"6": "Is Even",
},
}) {
t.Fatal(c)
t.Fatal(c2)
}
}

Expand Down

0 comments on commit 1fc20d5

Please sign in to comment.