34 lines
840 B
YAML
34 lines
840 B
YAML
|
|
desc: Tests that manipulation data in tables
|
||
|
|
table_variable_name: tbl
|
||
|
|
tests:
|
||
|
|
|
||
|
|
- def: obj = r.expr({'id':0,'a':0})
|
||
|
|
|
||
|
|
- py: tbl.insert([{'id':i, 'a':i} for i in xrange(3)])
|
||
|
|
js: |
|
||
|
|
tbl.insert(function(){
|
||
|
|
var res = []
|
||
|
|
for (var i = 0; i < 3; i++) {
|
||
|
|
res.push({id:i, 'a':i});
|
||
|
|
}
|
||
|
|
return res;
|
||
|
|
}())
|
||
|
|
rb: tbl.insert((0..2).map{ |i| { :id => i, :a => i } })
|
||
|
|
ot: ({'deleted':0,'replaced':0,'unchanged':0,'errors':0,'skipped':0,'inserted':3})
|
||
|
|
|
||
|
|
# Polymorphism
|
||
|
|
- cd:
|
||
|
|
- tbl.merge({'c':1}).nth(0)
|
||
|
|
- obj.merge({'c':1})
|
||
|
|
ot: ({'id':0,'c':1,'a':0})
|
||
|
|
|
||
|
|
- cd:
|
||
|
|
- tbl.without('a').nth(0)
|
||
|
|
- obj.without('a')
|
||
|
|
ot: ({'id':0})
|
||
|
|
|
||
|
|
- cd:
|
||
|
|
- tbl.pluck('a').nth(0)
|
||
|
|
- obj.pluck('a')
|
||
|
|
ot: ({'a':0})
|