2017-11-02 07:05:11 -07:00

152 lines
7.1 KiB
YAML

desc: secondary indexes on times
table_variable_name: tbl
tests:
- def:
rb: ts={"timezone"=>"-07:00","epoch_time"=>1375445162.0872,"$reql_type$"=>"TIME"}
py: ts={"timezone":"-07:00","epoch_time":1375445162.0872,"$reql_type$":"TIME"}
js: ts={"timezone":"-07:00","epoch_time":1375445162.0872,"$reql__type$":"TIME"}
- def:
rb: t1={"timezone"=>"-07:00","epoch_time"=>1375445163.0872,"$reql_type$"=>"TIME"}
py: t1={"timezone":"-07:00","epoch_time":1375445163.0872,"$reql_type$":"TIME"}
js: t1={"timezone":"-07:00","epoch_time":1375445163.0872,"$reql__type$":"TIME"}
- def:
rb: t2={"timezone"=>"-07:00","epoch_time"=>1375445163.08832,"$reql_type$"=>"TIME"}
py: t2={"timezone":"-07:00","epoch_time":1375445163.08832,"$reql_type$":"TIME"}
js: t2={"timezone":"-07:00","epoch_time":1375445163.08832,"$reql__type$":"TIME"}
- def:
rb: t3={"timezone"=>"-07:00","epoch_time"=>1375445163.08943,"$reql_type$"=>"TIME"}
py: t3={"timezone":"-07:00","epoch_time":1375445163.08943,"$reql_type$":"TIME"}
js: t3={"timezone":"-07:00","epoch_time":1375445163.08943,"$reql__type$":"TIME"}
- def:
rb: t4={"timezone"=>"-07:00","epoch_time"=>1375445163.09055,"$reql_type$"=>"TIME"}
py: t4={"timezone":"-07:00","epoch_time":1375445163.09055,"$reql_type$":"TIME"}
js: t4={"timezone":"-07:00","epoch_time":1375445163.09055,"$reql__type$":"TIME"}
- def:
rb: t5={"timezone"=>"-07:00","epoch_time"=>1375445163.09166,"$reql_type$"=>"TIME"}
py: t5={"timezone":"-07:00","epoch_time":1375445163.09166,"$reql_type$":"TIME"}
js: t5={"timezone":"-07:00","epoch_time":1375445163.09166,"$reql__type$":"TIME"}
- def:
rb: te={"timezone"=>"-07:00","epoch_time"=>1375445164.0872,"$reql_type$"=>"TIME"}
py: te={"timezone":"-07:00","epoch_time":1375445164.0872,"$reql_type$":"TIME"}
js: te={"timezone":"-07:00","epoch_time":1375445164.0872,"$reql__type$":"TIME"}
- def:
rb: trows = [{:id => t1}, {:id => t2}, {:id => t3}, {:id => t4}, {:id => t5}]
cd: trows = [{'id':t1}, {'id':t2}, {'id':t3}, {'id':t4}, {'id':t5}]
- cd: tbl.insert(trows)['inserted']
js: tbl.insert(trows)('inserted')
ot: 5
- def: bad_insert = [{'id':r.expr(t1).in_timezone("Z")}]
- cd: tbl.insert(bad_insert)['first_error']
js: tbl.insert(badInsert)('first__error')
ot: ("Duplicate primary key `id`:\n{\n\t\"id\":\t{\n\t\t\"$reql_type$\":\t\"TIME\",\n\t\t\"epoch_time\":\t1375445163.087,\n\t\t\"timezone\":\t\"-07:00\"\n\t}\n}\n{\n\t\"id\":\t{\n\t\t\"$reql_type$\":\t\"TIME\",\n\t\t\"epoch_time\":\t1375445163.087,\n\t\t\"timezone\":\t\"+00:00\"\n\t}\n}")
- cd: tbl.between(ts, te).count()
ot: 5
- cd: tbl.between(t1, t4).count()
ot: 3
- cd: tbl.between(t1, t4, :right_bound => 'closed').count()
py: tbl.between(t1, t4, right_bound='closed').count()
js: tbl.between(t1, t4, {rightBound:'closed'}).count()
ot: 4
- cd: tbl.between(r.expr(ts).in_timezone("+06:00"), te).count()
ot: 5
- cd: tbl.between(t1, r.expr(t4).in_timezone("+08:00")).count()
ot: 3
- cd: tbl.between(r.expr(t1).in_timezone("Z"), t4, :right_bound => 'closed').count()
py: tbl.between(r.expr(t1).in_timezone("Z"), t4, right_bound='closed').count()
js: tbl.between(r.expr(t1).inTimezone("Z"), t4, {rightBound:'closed'}).count()
ot: 4
- cd: tbl.update{|row| {:a => row[:id]}}['replaced']
py: tbl.update(lambda row:{'a':row['id']})['replaced']
js: tbl.update(function(row) {return {'a':row('id')}})('replaced')
ot: 5
- cd: tbl.index_create('a')
ot: ({'created':1})
- cd: tbl.index_wait('a').count()
ot: 1
- cd: tbl.between(ts, te, :index => 'a').count()
py: tbl.between(ts, te, index='a').count()
js: tbl.between(ts, te, {index:'a'}).count()
ot: 5
- cd: tbl.between(t1, t4, :index => 'a').count()
py: tbl.between(t1, t4, index='a').count()
js: tbl.between(t1, t4, {index:'a'}).count()
ot: 3
- cd: tbl.between(t1, t4, :right_bound => 'closed', :index => 'a').count()
py: tbl.between(t1, t4, right_bound='closed', index='a').count()
js: tbl.between(t1, t4, {rightBound:'closed', index:'a'}).count()
ot: 4
- cd: tbl.between(r.expr(ts).in_timezone("+06:00"), te, :index => 'a').count()
py: tbl.between(r.expr(ts).in_timezone("+06:00"), te, index='a').count()
js: tbl.between(r.expr(ts).inTimezone("+06:00"), te, {index:'a'}).count()
ot: 5
- cd: tbl.between(t1, r.expr(t4).in_timezone("+08:00"), :index => 'a').count()
py: tbl.between(t1, r.expr(t4).in_timezone("+08:00"), index='a').count()
js: tbl.between(t1, r.expr(t4).inTimezone("+08:00"), {index:'a'}).count()
ot: 3
- cd: tbl.between(r.expr(t1).in_timezone("Z"), t4, :right_bound => 'closed', :index => 'a').count()
py: tbl.between(r.expr(t1).in_timezone("Z"), t4, right_bound='closed', index='a').count()
js: tbl.between(r.expr(t1).inTimezone("Z"), t4, {rightBound:'closed', index:'a'}).count()
ot: 4
- cd: tbl.index_create('b'){|row| r.branch(row[:id] < t4, row[:a], null)}
py: tbl.index_create('b', lambda row:r.branch(row['id'] < t4, row['a'], null))
js: tbl.indexCreate('b', function(row) { return r.branch(row('id').lt(t4), row('a'), null); })
ot: ({'created':1})
- cd: tbl.index_wait('b').count()
ot: 1
- cd: tbl.index_wait('b').count()
ot: 1
- cd: tbl.between(ts, te, :index => 'b').count()
py: tbl.between(ts, te, index='b').count()
js: tbl.between(ts, te, {index:'b'}).count()
ot: 3
- cd: tbl.between(t1, t4, :index => 'b').count()
py: tbl.between(t1, t4, index='b').count()
js: tbl.between(t1, t4, {index:'b'}).count()
ot: 3
- cd: tbl.between(t1, t4, :right_bound => 'closed', :index => 'b').count()
py: tbl.between(t1, t4, right_bound='closed', index='b').count()
js: tbl.between(t1, t4, {rightBound:'closed', index:'b'}).count()
ot: 3
- cd: tbl.between(r.expr(ts).in_timezone("+06:00"), te, :index => 'b').count()
py: tbl.between(r.expr(ts).in_timezone("+06:00"), te, index='b').count()
js: tbl.between(r.expr(ts).inTimezone("+06:00"), te, {index:'b'}).count()
ot: 3
- cd: tbl.between(t1, r.expr(t4).in_timezone("+08:00"), :index => 'b').count()
py: tbl.between(t1, r.expr(t4).in_timezone("+08:00"), index='b').count()
js: tbl.between(t1, r.expr(t4).inTimezone("+08:00"), {index:'b'}).count()
ot: 3
- cd: tbl.between(r.expr(t1).in_timezone("Z"), t4, :right_bound => 'closed', :index => 'b').count()
py: tbl.between(r.expr(t1).in_timezone("Z"), t4, right_bound='closed', index='b').count()
js: tbl.between(r.expr(t1).inTimezone("Z"), t4, {rightBound:'closed', index:'b'}).count()
ot: 3
- def:
rb: oldtime = Time.at(1375147296.681)
py: oldtime = datetime.fromtimestamp(1375147296.681, PacificTimeZone())
js: oldtime = (new Date(1375147296.681*1000))
- def:
rb: curtime = Time.now
py: curtime = datetime.now()
js: curtime = (new Date())
- cd: tbl.insert([{'id':oldtime}])['inserted']
js: tbl.insert([{'id':oldtime}])('inserted')
ot: 1
# - cd: tbl.insert([{'id':oldtime}, {'id':curtime}])['inserted']
# ot: 1
- cd: tbl.get(oldtime)['id'].type_of()
js: tbl.get(oldtime)('id').typeOf()
ot: ("PTYPE<TIME>")