Created
February 1, 2011 20:15
-
-
Save bernerdschaefer/806572 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Notification | |
property :name, String | |
belongs_to :user | |
end | |
class User | |
has n, :notifications | |
end | |
# Find all users with no notifications | |
User.all(:notifications => nil) | |
# Find all users with no notifications w/ a particular name? | |
# This doesn't work as expected, because "notifications.name" will | |
# be turned into an inner join, making the :notifications => nil condition | |
# moot. | |
User.all(:notifications => nil, "notifications.name" => "SomeName") | |
# Is this the only way to accomplish this? | |
User.has n, :some_name_notifications, :name => "SomeName" | |
User.all(:some_name_notifications => nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This type of "negative" query generally sucks.