RolifyCommunity/rolify — pull request #281 by rmckayfleming (2014-09-08 15:24:38+00:00)
Title: Fixes quoting for STI.

Query used to look like this:
```SQL
SELECT `groups`.* FROM `groups` INNER JOIN `roles` ON `roles`.resource_type IN (`Campus`, `Group`) AND
(`roles`.resource_id IS NULL OR `roles`.resource_id = `groups`.id) WHERE (`roles`.name IN ('group_insight') AND `roles`.resource_type IN ('Campus','Group')) AND (`roles`.id IN (SELECT `roles`.id FROM `roles` INNER JOIN `users_roles` ON `roles`.`id` = `users_roles`.`role_id` WHERE `users_roles`.`user_id` = 26098 AND `roles`.`name` = 'group_insight') AND ((resource_id = `groups`.id) OR (resource_id IS NULL)))
```
This caused a Unknown column 'Group' in 'on clause'

Should now generate the correct:

```SQL
SELECT `groups`.* FROM `groups` INNER JOIN `roles` ON `roles`.resource_type IN ('Campus', 'Group') AND
(`roles`.resource_id IS NULL OR `roles`.resource_id = `groups`.id) WHERE (`roles`.name IN ('group_insight') AND `roles`.resource_type IN ('Campus','Group')) AND (`roles`.id IN (SELECT `roles`.id FROM `roles` INNER JOIN `users_roles` ON `roles`.`id` = `users_roles`.`role_id` WHERE `users_roles`.`user_id` = 26098 AND `roles`.`name` = 'group_insight') AND ((resource_id = `groups`.id) OR (resource_id IS NULL)))
```