Fix #4688: Malformed SQL when searching -status:any.

Negating `Post.all` produced the invalid SQL fragment `WHERE NOT ()`.
Use `Post.where("TRUE")` instead to produce `WHERE NOT (TRUE)`.
This commit is contained in:
evazion
2021-02-03 21:15:58 -06:00
parent e90f792e20
commit 19974d3ab1
2 changed files with 8 additions and 1 deletions

View File

@@ -639,6 +639,13 @@ class PostQueryBuilderTest < ActiveSupport::TestCase
assert_tag_match([disapproved], "-status:unmoderated")
end
should "return nothing for the -status:any metatag" do
create(:post)
assert_tag_match([], "-status:any")
assert_tag_match([], "-status:all")
end
should "respect the 'Deleted post filter' option when using the status: metatag" do
deleted = create(:post, is_deleted: true, is_banned: true)
undeleted = create(:post, is_banned: true)