ruby
require 'rubygems'
require 'dm-core'
require 'spec'
DataMapper::Logger.new(STDOUT, :debug)
DataMapper.setup :default, "sqlite3::memory:"
class User
include DataMapper::Resource
property :id, Serial
property :active, Boolean
default_scope(:default).update(:active => true)
auto_migrate!
end
describe "Overwriting default scope conditions" do
before :all do
= User.create(:active => true)
= User.create(:active => false)
end
it "should overwrite a condition" do
users = User.all(:active => false)
users.size.should == 1
users.first.should ==
end
end
The produced query looks like this:
SELECT "id", "active" FROM "users" WHERE ("active" = 'f' AND "active" = 't') ORDER BY "id"
Created by Piotr Solnica (solnic) - 2010-02-24 12:30:04 UTC
Original Lighthouse ticket: http://datamapper.lighthouseapp.com/projects/20609/tickets/1202
该提问来源于开源项目:datamapper/dm-core