A Recruiter belongs to a Team.

Suppose I do

Recruiter.first(:team_id => 'foo')

That generates a simple query:
~ (0.002456) SELECT `id`, `created_at`, `updated_at`, ... `team_id`
FROM `recruiters` WHERE `team_id` = 'foo' ORDER BY `id` LIMIT 1

Now suppose I do:
Recruiter.first('team.id' => 'foo')

That generates:
~ (0.008210) SELECT `recruiters`.`id`, `recruiters`.`created_at`,
`recruiters`.`updated_at`, ... `recruiters`.`team_id` FROM
`recruiters` INNER JOIN `teams` ON `recruiters`.`team_id` =
`teams`.`id` WHERE `teams`.`id` = '554' GROUP BY `recruiters`.`id`,
`recruiters`.`created_at`, `recruiters`.`updated_at`, ...
`recruiters`.`team_id` ORDER BY `recruiters`.`id` LIMIT 1

What I don't understand is why doesn't the second query just do:

~ (0.008210) SELECT `recruiters`.`id`, `recruiters`.`created_at`,
`recruiters`.`updated_at`, ... `recruiters`.`team_id` FROM
`recruiters` INNER JOIN `teams` ON `recruiters`.`team_id` =
`teams`.`id` WHERE `teams`.`id` = '554' ORDER BY `recruiters`.`id`
LIMIT 1

?

For that matter, are there any underlying efficiency concerns in the
DB regarding the superfluous group_by?

Thanks,
Gary

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" group.
To post to this group, send email to datamapper@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