acts_as_paranoid icon indicating copy to clipboard operation
acts_as_paranoid copied to clipboard

Could you please support boolean with default set to false, rather than NULL?

Open leisun opened this issue 13 years ago • 4 comments

Hi,

I noticed that you have the following lines:

default_scope where("#{paranoid_column_reference} IS ?", nil) # Magic!

and

def only_deleted self.unscoped.where("#{paranoid_column_reference} IS NOT ?", nil) end

This would work ok for relatively smaller table, but not a huge one, where I would add index for is_deleted field.

Could you please add the support for is_deleted field and assuming the default to be set to false rather than NULL?

Thanks

-lei

leisun avatar Jul 04 '11 21:07 leisun

This should be currently supported.

goncalossilva avatar Dec 09 '12 16:12 goncalossilva

It's not supported. I'm using monkey patch below to achieve desired behavior:

  def self.paranoid_default_scope_sql
    self.scoped.table[paranoid_column].eq(false).to_sql
  end

  def self.only_deleted
    without_paranoid_default_scope.where("#{paranoid_column_reference}" => true)
  end

I don't think it's good though (recovery probably would fail but I'm not using it yet). Could you add support for boolean columns with true/false values?

pranas avatar Jan 06 '13 02:01 pranas

@goncalossilva are you going to work on it? I'm willing to implement it and prepare a pull request.

pranas avatar Jan 20 '13 19:01 pranas

@Pranas That would be great!

goncalossilva avatar Jan 21 '13 09:01 goncalossilva