Skip to content

Commit

Permalink
Fix #13
Browse files Browse the repository at this point in the history
  • Loading branch information
Florimond committed Jul 25, 2021
1 parent 77dc531 commit f7f10e0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion column_strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func (c *columnString) Apply(r *commit.Reader) {
for r.Next() {
if r.Type == commit.Put {
c.fill[r.Offset>>6] |= 1 << (r.Offset & 0x3f)
c.data[r.Offset] = r.String()
c.data[r.Offset] = string(r.Bytes())
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions column_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,3 +315,24 @@ func addAny(cur *Cursor, column string, value interface{}) {
panic(fmt.Errorf("column: unsupported type (%T)", value))
}
}

func TestForString(t *testing.T) {
coll := NewCollection()
coll.CreateColumn("id", ForInt64())
coll.CreateColumn("data", ForString())
coll.CreateIndex("one", "id", func(r Reader) bool {
return r.Int() == 1
})

data := []string{"a", "b", "c", "d"}

for i, d := range data {
coll.Insert(map[string]interface{}{"id": i, "data": d})
}
coll.Query(func(tx *Txn) error {
tx.With("one").Select(func(v Selector) {
assert.Equal(t, "b", v.StringAt("data"))
})
return nil
})
}
1 change: 1 addition & 0 deletions txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ func (p *txnPool) acquire(owner *Collection) *Txn {
txn := p.txns.Get().(*Txn)
txn.owner = owner
txn.writer = owner.writer
txn.index.Grow(uint32(owner.size))
owner.fill.Clone(&txn.index)
return txn
}
Expand Down

0 comments on commit f7f10e0

Please sign in to comment.