#1498 new
DGaff

dm-chunked_query raises immutable in strange case

Reported by DGaff | March 23rd, 2011 @ 12:08 AM

I have been messing around with the dm-chunked_query library, and it seems that when you have code like this, the Immutable error is raised, although all the subsequent examples seem fine:

An error:

Model.all(:fields => [...]).chunks(20) do |chunk|
keys = chunk.first.attributes.keys
chunk.each do |row|
row_keys = keys.collect{|k| row.attributes[k]}
end
end
delete this gist
Comments are parsed with GitHub Flavored Markdown

/Library/Ruby/Gems/1.8/gems/dm-core-1.0.2/lib/dm-core/resource/state/immutable.rb:9:in `get': Immutable resource cannot be lazy loaded (DataMapper::ImmutableError)

This works:

chunk = Model.all(:fields => [...]).chunks(20)
keys = chunk.first.attributes
keys.collect{|k| chunk.last.attributes[k]}

As does this:

chunk = Model.all(:fields => [...]).chunks(20)
keys = chunk.first.attributes
row = chunk.last
keys.collect{|k| row.attributes[k]}

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Pages