I experience the same issue with MySQL 5 using dm-core 0.10.2

The generated SQL looks for the wrong ID. My workaround is to first
get the "orange label" then list all its posts:

label = Label.first(:name => 'orange')
posts = label.posts

This seems to work for me.

Kevin

On Feb 13, 9:22 am, casual <kab...@gmail.com> wrote:
> I believe that only works in SQL and not SQLite3
>
> On Feb 11, 2:49 pm, Woongcheol Yang <woongch...@gmail.com> wrote:
>
> > Hello all,
>
> > I just started learning DataMapper and I'm stuck at what I think should be
> > pretty simple.
>
> > My models look like this:
>
> > class Post
> >      include DataMapper::Resource
> >      has n, :labels, :through => Resource
> > end
>
> > class Label
> >      include DataMapper::Resource
> >      property :name, String
> >      has n, :posts, :through => Resource
> > end
>
> > they both have some extra properties which I omitted. Other than that they
> > exactly follow the examples given in DataMapper associations documentation.
>
> > When I query like this:
>
> > Post.all( :labels => { :name => 'orange' } )
>
> > I want to get all posts that has a label named orange. What it is giving me
> > instead is a post whose id is same as the id of the label named orange. More
> > confusingly, when I query:
>
> > Post.all( :labels => Label.get(4) )
>
> > I get what I would get with Post.get(4). I double-checked that the post with
> > id 4 is not associated with the label with id 4 in the database.
>
> > I would really appreciate if someone could teach me what I'm doing wrong
> > here.
>
> > I'm using dm-core 0.10.2 with sqlite3.
>
> > wy

-- 
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamap...@googlegroups.com.
To unsubscribe from this group, send email to 
datamapper+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/datamapper?hl=en.

Reply via email to