set profile attr for columnLabel

This commit is contained in:
Linh Vo 2017-03-24 12:18:59 -05:00
parent 318a8a9f19
commit 7979b4d69b
2 changed files with 16 additions and 10 deletions

View file

@ -271,7 +271,7 @@ func encodePair(p Pair) *internal.Pair {
func decodePair(pb *internal.Pair) Pair {
return Pair{
ID: pb.Key,
ID: pb.Key,
Count: pb.Count,
}
}

View file

@ -772,21 +772,27 @@ func (e *Executor) executeBulkSetBitmapAttrs(ctx context.Context, db string, cal
// executeSetProfileAttrs executes a SetProfileAttrs() call.
func (e *Executor) executeSetProfileAttrs(ctx context.Context, db string, c *pql.Call, opt *ExecOptions) error {
id, ok := c.Args["id"].(uint64)
if !ok {
return errors.New("SetProfileAttrs() id required")
}
// Copy args and remove reserved fields.
attrs := pql.CopyArgs(c.Args)
delete(attrs, "id")
// Retrieve database.
d := e.Index.DB(db)
if d == nil {
return ErrDatabaseNotFound
}
id, ok := c.Args["id"].(uint64)
if !ok {
// Retrieve columnLabel
columnLabel := d.columnLabel
col, ok := c.Args[columnLabel].(uint64)
if !ok {
return errors.New("SetProfileAttrs() id required")
}
id = col
}
// Copy args and remove reserved fields.
attrs := pql.CopyArgs(c.Args)
delete(attrs, "id")
// Set attributes.
if err := d.ProfileAttrStore().SetAttrs(id, attrs); err != nil {
return err