I believe this is a bug, I just wrote a test for it in the current dm-
core and it fails:
--------------------------------
# in resource_shared_spec/ describe 'lazy loading'
describe "with context" do
before(:all) do
rescue_if @skip do
comment = @comment_model.create(:body => 'I really like your
Def Jux baby tee.', :url => 'http://blog.foo.com', :gravatar_url =>
'http://gravatar.com/image.png', :user => @user)
@comment = @comment_model.get(*comment.key)
end
end
it "should not fetch the lazy keys" do
@comment_model.properties[:url].loaded?(@comment).should_not
be(true)
@comment_model.properties[:gravatar_url].loaded?
(@comment).should_not be(true)
end
it "should fetch all lazy kys in the context" do
@comment.url
@comment_model.properties[:url].loaded?(@comment).should
be(true)
@comment_model.properties[:gravatar_url].loaded?
(@comment).should be(true) # => fails a returning false
end
end
-----------------------------
I will take a look at the lighthouse project and see if there is a
ticket for this already, if not I'll file one.
On Feb 11, 6:00 pm, daniel_spaniel <[email protected]> wrote:
> Hi
> I am following the documentation about lazy loading properties. I
> especially liked the concept of grouping the lazy loading properties
> together. So I tried it. But when I look at the sql it does not really
> happen as expected.
>
> DataMapper.setup(:default, 'sqlite3://:memory:')
>
> class Post
> include DataMapper::Resource
>
> property :id, Serial
> property :name, String, :lazy => [:show]
> property :volume, Integer, :lazy => [:show]
> property :idea, String, :lazy => [:report]
>
> end
>
> Post.auto_migrate!
> Post.create(:name=>'Dan',:volume=>5,:idea=>'moo')
>
> Post.first.name
>
> When I look at query for ( Post.first.name ) I see only the name
> property loaded, not the name and volume together which I thought was
> supposed to happen since they are in the same lazy :show group.
> Am I doing something wrong?
>
> ~ Dan
--
You received this message because you are subscribed to the Google Groups
"DataMapper" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/datamapper?hl=en.