acts_as_paranoid
acts_as_paranoid copied to clipboard
Could you please support boolean with default set to false, rather than NULL?
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
This should be currently supported.
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 are you going to work on it? I'm willing to implement it and prepare a pull request.
@Pranas That would be great!