S
Sharon Rosner
Hi gang
I've stumbled upon a weird phenomenon when trying nested Dataset#query
methods with Sequel:
ds = DB[:items].query do
select :x, :y
where :x => DB[:stuff].query do
select :a
where :b => DB[:misc].query do
select :c
where :d => true
end
end
end
#=> /usr/local/lib/ruby/gems/1.8/gems/sequel-0.2.0.2/lib/sequel/../
sequel/dataset/convenience.rb:217:in `instance_eval': block not
supplied (ArgumentError)
If I enclose the nested procs in parens everything works fine:
ds = DB[:items].query do
select :x, :y
where :x => (DB[:stuff].query do
select :a
where :b => (DB[:misc].query do
select :c
where :d => true
end)
end)
end
It also works if I use the curly brackets notation:
ds = DB[:items].query {
select :x, :y
where :x => DB[:stuff].query {
select :a
where :b => DB[:misc].query {
select :c
where :d => true
}
}
}
Is the error above the intended behavior? If it is, can someone
explain what's going on?
best
Sharon
I've stumbled upon a weird phenomenon when trying nested Dataset#query
methods with Sequel:
ds = DB[:items].query do
select :x, :y
where :x => DB[:stuff].query do
select :a
where :b => DB[:misc].query do
select :c
where :d => true
end
end
end
#=> /usr/local/lib/ruby/gems/1.8/gems/sequel-0.2.0.2/lib/sequel/../
sequel/dataset/convenience.rb:217:in `instance_eval': block not
supplied (ArgumentError)
If I enclose the nested procs in parens everything works fine:
ds = DB[:items].query do
select :x, :y
where :x => (DB[:stuff].query do
select :a
where :b => (DB[:misc].query do
select :c
where :d => true
end)
end)
end
It also works if I use the curly brackets notation:
ds = DB[:items].query {
select :x, :y
where :x => DB[:stuff].query {
select :a
where :b => DB[:misc].query {
select :c
where :d => true
}
}
}
Is the error above the intended behavior? If it is, can someone
explain what's going on?
best
Sharon