That all worked, thanks much!

On Thursday, July 23, 2015 at 7:14:13 PM UTC-7, Jeremy Evans wrote:
>
> On Thursday, July 23, 2015 at 4:36:52 PM UTC-7, [email protected] 
> <javascript:> wrote:
>>
>> Also, here is the actual SQL.
>>
>>
>> FYI - I'm pretty sure the group by is only because of the order by which 
>> is not in the *query.rb* gist I gave but is in the 
>> *original_datamapper_classes.rb* gist...hence all the properties also 
>> being listed.  *So that part of the query you can ignore.*
>>
>> *DataMapper SQL*
>> SELECT `people`.`id`, `people`.`created_date`, ......(all properties).... 
>> FROM `people` 
>> INNER JOIN `group_people` ON `people`.`id` = `group_people`.`person_id` 
>> INNER JOIN `groups` ON 
>>     `group_people`.`group_id` = `groups`.`id` 
>>     AND 
>>     `group_people`.`group_school_id` = `groups`.`school_id` 
>> WHERE (`groups`.`ems_type` = 'Ready' AND `people`.`first_name` = 'Bob') 
>> GROUP BY `people`.`id`, `people`.`created_date`,  ......(all 
>> properties)....  
>> ORDER BY `people`.`id`
>>
>> *Sequel SQL*
>> SELECT * FROM `people` 
>> WHERE 
>>     ((`group` IN (SELECT * FROM `groups` WHERE (`ems_type` = 'Ready'))) 
>>     AND 
>>     (`first_name` = 'Bob'))
>>
>
> This is because you are using :group instead of :groups (you have to use 
> the association name, not the singular version).
>
> The foreign key violations appear to be due to invalid references, i.e. 
> you are trying to add a group_people record with a person_id where no 
> person with that id exists in the person table. Try switching to 
> Group.create and Person.create (which save the objects) instead of 
> Group.new and Person.new (which don't save the objects).
>
> Thanks,
> Jeremy
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to