This project is archived and is in readonly mode.

#3838 ✓resolved

with_exclusive_scope does not override the default_scope when each provides IS NULL / IS NOT NULL conditions

Reported by foca | February 1st, 2010 @ 10:36 PM | in 3.0.2

class Page < ActiveRecord::Base
  default_scope where(:deleted_at => nil)

  def self.deleted
    with_exclusive_scope :find => where('pages.deleted_at IS NOT NULL') do

Page.all emits this SQL:

SELECT "pages".* FROM "pages" WHERE ("pages"."deleted_at" IS NULL)

While Page.deleted.all emits this:

SELECT "pages".* FROM "pages" WHERE ("pages"."deleted_at" IS NULL) AND ("pages"."deleted_at" IS NOT NULL)

Attached is a failing test.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href=""></a>