victor-axelsson / id2210

0 stars 0 forks source link

Get object from lists #10

Closed victor-axelsson closed 7 years ago

victor-axelsson commented 7 years ago

About

We currently cannot get items from lists.

{
   "someLists":[{"someItem": "abc123"}]
}

We cannot get to this "someItem" object and assign a value to it. It has to do with how the cursor works.

To recreate

val eval = new Evaluator(1)
val insertSomeIndex1 = InsertAfter(EmptyMap)
val insertreg= Assign(new Str("someVal"))

eval evalExpr Doc() evalExpr Get("someVar") evalExpr Get("someVar2") evalExpr Idx(0) evalCmd insertSomeIndex1
eval evalExpr Doc() evalExpr Get("someVar") evalExpr Get("someVar2") evalExpr Idx(0) evalExpr  Get("someVar3") evalCmd  insertreg

var s:String = eval.toJsonString()
var expectedOutput = "<some expected output>"
assert(s == expectedOutput)

This is copy pasted from victorDev branch unit test

How to solve

When we build the cursor we use an identifierT(<int>) to mark and index of the array. This kind of sux. It would be better to have an idxT(<int>) or something to mark a traversal into an index of the array.

Watch out

Let's hope to the coding gods that the unit tests are properly written so that they cover when you add another datatype.

Also, watch out for tombstones. When you set an index of traversal, that should skip the tombstones.

victor-axelsson commented 7 years ago

Ok, so this seems to work now. Yeey!