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