Fix invalid query syntax when `CategoryCustomField#value` is blank.
This commit is contained in:
parent
663d78414b
commit
7a2bf8e368
|
@ -388,9 +388,10 @@ class Category < ActiveRecord::Base
|
||||||
|
|
||||||
def self.auto_bump_topic!
|
def self.auto_bump_topic!
|
||||||
bumped = false
|
bumped = false
|
||||||
|
|
||||||
auto_bumps = CategoryCustomField
|
auto_bumps = CategoryCustomField
|
||||||
.where(name: Category::NUM_AUTO_BUMP_DAILY)
|
.where(name: Category::NUM_AUTO_BUMP_DAILY)
|
||||||
.where('value::int > 0')
|
.where('NULLIF(value, \'\')::int > 0')
|
||||||
.pluck(:category_id)
|
.pluck(:category_id)
|
||||||
|
|
||||||
if (auto_bumps.length > 0)
|
if (auto_bumps.length > 0)
|
||||||
|
@ -399,6 +400,7 @@ class Category < ActiveRecord::Base
|
||||||
break if bumped
|
break if bumped
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
bumped
|
bumped
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -734,6 +734,11 @@ describe Category do
|
||||||
category.auto_bump_limiter.clear!
|
category.auto_bump_limiter.clear!
|
||||||
expect(Category.auto_bump_topic!).to eq(true)
|
expect(Category.auto_bump_topic!).to eq(true)
|
||||||
expect(Topic.where(bumped_at: time).count).to eq(1)
|
expect(Topic.where(bumped_at: time).count).to eq(1)
|
||||||
|
|
||||||
|
category.num_auto_bump_daily = ""
|
||||||
|
category.save!
|
||||||
|
|
||||||
|
expect(Category.auto_bump_topic!).to eq(false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue