Skip to content

Instantly share code, notes, and snippets.

@krzysztofjablonski
Created August 13, 2011 13:17
Show Gist options
  • Save krzysztofjablonski/1143843 to your computer and use it in GitHub Desktop.
Save krzysztofjablonski/1143843 to your computer and use it in GitHub Desktop.
bug in datamapper
class Transaction
include DataMapper::Resource
property :user_id, Integer
def self.u1
all(:conditions => ["user_id != 4"])
end
def self.u2
all(:conditions => ["user_id != 5"])
end
def self.u3
all(:conditions => ["user_id != 6"])
end
end
Console:
Transaction.u1.count
SQL (0.270ms) SELECT COUNT(*) FROM `transactions` WHERE (user_id != 4)
Transaction.u1.u2.count
SQL (0.311ms) SELECT COUNT(*) FROM `transactions` WHERE ((user_id != 4) AND (user_id != 5))
Transaction.u1.u2.u3.count
SQL (0.312ms) SELECT COUNT(*) FROM `transactions` WHERE ((user_id != 5) AND (user_id != 6))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment