Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corrected the documentation for column_type: 'boolean' #294

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -74,11 +74,12 @@ marking an object as deleted by passing `:deleted_value` (default is
"deleted"). Any records with a non-matching value in this column will be
treated normally, i.e., as not deleted.

If your column type is a `boolean`, it is possible to specify `allow_nulls`
option which is `true` by default. When set to `false`, entities that have
If your column type is a `boolean`, it is possible to specify an `allow_nulls`
option, which is `false` by default. When set to `false`, entities that have
`false` value in this column will be considered not deleted, and those which
have `true` will be considered deleted. When `true` everything that has a
not-null value will be considered deleted.
have `true` will be considered deleted (`NULL` values deliver unexpected
results!). When `true`, everything that has a not-null value will be considered
deleted.

### Filtering

8 changes: 8 additions & 0 deletions test/test_core.rb
Original file line number Diff line number Diff line change
@@ -342,6 +342,14 @@ def test_fake_removal
assert_equal 1, ParanoidString.with_deleted.count
end

def test_boolean_nil_value_is_bad
ParanoidBoolean.create! name: "null flag", is_deleted: nil

assert_equal 3, ParanoidBoolean.count
assert_equal 4, ParanoidBoolean.with_deleted.count
assert_equal 0, ParanoidBoolean.only_deleted.count
end

def test_real_removal
ParanoidTime.first.destroy_fully!
ParanoidBoolean.delete_all!("name = 'extremely paranoid' OR name = 'really paranoid'")