Re: [DataMapper] non-existent `id` column thrown in every get query/join

41 views
Skip to first unread message

Andre Lima

unread,
Nov 15, 2012, 4:55:44 AM11/15/12
to datam...@googlegroups.com
Jeff,

Remove :key => true ( this is used only if the field is different of Serial )

Andre Lima

On 14/11/2012, at 23:20, Jeff Ruhl <ruh...@gmail.com> wrote:

Given the following class

class Post
   include DataMapper::Resource

   property :id, Serial, :field => 'post_id', :key => true
   property :thread_id, Integer
   property :username, String
   property :post_date, Integer
   property :message, Text

end
 
executing 'Post.get(1)' produces the following sql

SELECT `post_id`, `id`, `username`, `date`, `id`, `id` FROM `xf_post` WHERE `post_id` = 1 LIMIT 1

I've also tried changing the :id property name to all forms of insanity, but DataMapper keeps tacking the `id` column in the queries.
Is there a configuration somewhere to turn off assuming an id column? I'm mapping over a legacy database. 
 

--
You received this message because you are subscribed to the Google Groups "DataMapper" group.
To view this discussion on the web visit https://groups.google.com/d/msg/datamapper/-/456dN_dlh9wJ.
To post to this group, send email to datam...@googlegroups.com.
To unsubscribe from this group, send email to datamapper+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.

Jeff Ruhl

unread,
Jan 10, 2013, 7:01:44 PM1/10/13
to datam...@googlegroups.com
It's now querying for `id` 3 times.
Resulting sql
SELECT `post_id`, `id`, `username`, `date`, `id`, `id` FROM `xf_post` WHERE `post_id` = 1 LIMIT 1

Abe Voelker

unread,
Jan 10, 2013, 10:48:34 PM1/10/13
to datam...@googlegroups.com
Any different result if you get rid of the Serial type?

property :id, Integer, :field => 'post_id', :key => true

Jeff Ruhl

unread,
Jan 12, 2013, 9:07:56 AM1/12/13
to datam...@googlegroups.com
It generated the same query
Reply all
Reply to author
Forward
0 new messages