2019-10-21 18:32:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class ActiveRecord::Relation
|
|
|
|
def pluck_first(*attributes)
|
2023-02-13 12:39:45 +08:00
|
|
|
Discourse.deprecate("`#pluck_first` is deprecated, use `#pick` instead.")
|
|
|
|
pick(*attributes)
|
2019-10-21 18:32:27 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def pluck_first!(*attributes)
|
2023-02-13 12:39:45 +08:00
|
|
|
Discourse.deprecate("`#pluck_first!` is deprecated without replacement.")
|
|
|
|
items = pick(*attributes)
|
2019-10-21 18:32:27 +08:00
|
|
|
|
2023-02-13 12:39:45 +08:00
|
|
|
raise_record_not_found_exception! if items.nil?
|
2019-10-21 18:32:27 +08:00
|
|
|
|
2023-02-13 12:39:45 +08:00
|
|
|
items
|
2019-10-21 18:32:27 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module ActiveRecord::Querying
|
|
|
|
delegate(:pluck_first, :pluck_first!, to: :all)
|
|
|
|
end
|