Skip to content

Commit 924f5c5

Browse files
committed
Rename find_records to allow detection of overrides that will break during upgrade
1 parent 6ef031b commit 924f5c5

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/jsonapi/active_relation_resource_finder.rb

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@ def find(filters, options = {})
2525

2626
paginator = options[:paginator]
2727

28-
records = find_records(records: records(options),
29-
sort_criteria: sort_criteria,
30-
filters: filters,
28+
records = apply_request_settings_to_records(records: records(options),
29+
sort_criteria: sort_criteria,filters: filters,
3130
join_manager: join_manager,
3231
paginator: paginator,
3332
options: options)
@@ -45,7 +44,7 @@ def count(filters, options = {})
4544
join_manager = JoinManager.new(resource_klass: self,
4645
filters: filters)
4746

48-
records = find_records(records: records(options),
47+
records = apply_request_settings_to_records(records: records(options),
4948
filters: filters,
5049
join_manager: join_manager,
5150
options: options)
@@ -100,7 +99,7 @@ def find_fragments(filters, options = {})
10099

101100
paginator = options[:paginator]
102101

103-
records = find_records(records: records(options),
102+
records = apply_request_settings_to_records(records: records(options),
104103
filters: filters,
105104
sort_criteria: sort_criteria,
106105
paginator: paginator,
@@ -229,7 +228,7 @@ def count_related(source_rid, relationship_name, options = {})
229228
source_relationship: relationship,
230229
filters: filters)
231230

232-
records = find_records(records: records(options),
231+
records = apply_request_settings_to_records(records: records(options),
233232
resource_klass: related_klass,
234233
primary_keys: source_rid.id,
235234
join_manager: join_manager,
@@ -306,13 +305,13 @@ def to_one_relationships_for_linkage(include_related)
306305
end
307306

308307
def find_record_by_key(key, options = {})
309-
record = find_records(records: records(options), primary_keys: key, options: options).first
308+
record = apply_request_settings_to_records(records: records(options), primary_keys: key, options: options).first
310309
fail JSONAPI::Exceptions::RecordNotFound.new(key) if record.nil?
311310
record
312311
end
313312

314313
def find_records_by_keys(keys, options = {})
315-
find_records(records: records(options), primary_keys: keys, options: options)
314+
apply_request_settings_to_records(records: records(options), primary_keys: keys, options: options)
316315
end
317316

318317
def find_related_monomorphic_fragments(source_rids, relationship, options, connect_source_identity)
@@ -337,7 +336,7 @@ def find_related_monomorphic_fragments(source_rids, relationship, options, conne
337336

338337
paginator = options[:paginator] if source_rids.count == 1
339338

340-
records = find_records(records: records(options),
339+
records = apply_request_settings_to_records(records: records(options),
341340
resource_klass: resource_klass,
342341
sort_criteria: sort_criteria,
343342
primary_keys: source_ids,
@@ -464,7 +463,7 @@ def find_related_polymorphic_fragments(source_rids, relationship, options, conne
464463

465464
# Note: We will sort by the source table. Without using unions we can't sort on a polymorphic relationship
466465
# in any manner that makes sense
467-
records = find_records(records: records(options),
466+
records = apply_request_settings_to_records(records: records(options),
468467
resource_klass: resource_klass,
469468
sort_primary: true,
470469
primary_keys: source_ids,
@@ -615,7 +614,7 @@ def find_related_polymorphic_fragments(source_rids, relationship, options, conne
615614
related_fragments
616615
end
617616

618-
def find_records(records:,
617+
def apply_request_settings_to_records(records:,
619618
join_manager: JoinManager.new(resource_klass: self),
620619
resource_klass: self,
621620
filters: {},

0 commit comments

Comments
 (0)