weixin_39782500 2020-11-22 01:58
浏览 0

Overwriting default_scope conditions is broken

 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

  • 写回答

5条回答 默认 最新

  • weixin_39782500 2020-11-22 01:58
    关注

    I can confirm that this issue is reproducible on 0.10.2 and on master branch.

    by Marcin Kulik

    评论

报告相同问题?