#1020 confirmed
Robert Sköld

Collection#concat doesn't update query for lazy_loading

Reported by Robert Sköld | August 24th, 2009 @ 12:55 PM

Example program which illustrates the issue (tested with ruby 1.8.6 (2008-08-11) [universal-darwin9.0]):

require "rubygems"
require "dm-core"
require "dm-serializer"

class Item
  include DataMapper::Resource
  property :id,               Serial
  property :title,            String
  property :kind,             Integer
  property :content,          Text  

DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup(:default, "sqlite3://#{Dir.pwd}/test.db")

0.upto(100) do |i| 
  item = Item.create( :title => "item#{i}" , :content => "bla blab la " , :kind => ( rand() > 0.5 ? 1 : 2 ) )

as = Item.all( :kind => 1 )
bs = Item.all( :kind => 2 )

merged = as.concat( bs )

puts "Merged: #{merged.size}" # => 101

puts "Without json: #{merged.map { |item| item }.size}" # => 101
puts "With json: #{merged.map { |item| item.to_json }.size} (should be 101)" # => ~50

Edit: Updated example, it has the same error without the "has n" so now it's more compact and to the point.

Comments and changes to this ticket

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 »