Skip to content
This repository has been archived by the owner on Jun 30, 2021. It is now read-only.

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

Open
leisun opened this issue Jul 4, 2011 · 4 comments

Comments

@leisun
Copy link

leisun commented Jul 4, 2011

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

@goncalossilva
Copy link
Owner

This should be currently supported.

@pranas
Copy link

pranas commented Jan 6, 2013

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?

@goncalossilva goncalossilva reopened this Jan 6, 2013
@pranas
Copy link

pranas commented Jan 20, 2013

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

@goncalossilva
Copy link
Owner

@pranas That would be great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants