Skip to content

Commit ed2bc92

Browse files
authored
Merge pull request rails#50162 from misdoro/50160_allow_object_id_column_name
Allow `object_id` as a column name for ActiveRecord
2 parents 6f394ff + 622c58c commit ed2bc92

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

activerecord/lib/active_record/attribute_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def dangerous_attribute_methods # :nodoc:
3333
Base.private_instance_methods -
3434
Base.superclass.instance_methods -
3535
Base.superclass.private_instance_methods +
36-
%i[__id__ dup freeze frozen? hash object_id class clone]
36+
%i[__id__ dup freeze frozen? hash class clone]
3737
).map { |m| -m.to_s }.to_set.freeze
3838
end
3939
end

activerecord/test/cases/associations_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,7 +1261,7 @@ def test_preload_with_available_records_with_through_association
12611261
end
12621262

12631263
assert_predicate author.association(:essay_category), :loaded?
1264-
assert categories.map(&:object_id).include?(author.essay_category.object_id)
1264+
assert categories.map(&:__id__).include?(author.essay_category.__id__)
12651265
end
12661266

12671267
def test_preload_with_only_some_records_available_with_through_associations
@@ -1307,7 +1307,7 @@ def test_preload_with_available_records_queries_when_scoped
13071307
end
13081308

13091309
assert_predicate post.association(:author), :loaded?
1310-
assert_not_equal david.object_id, post.author.object_id
1310+
assert_not_equal david.__id__, post.author.__id__
13111311
end
13121312

13131313
def test_preload_with_available_records_queries_when_collection
@@ -1319,7 +1319,7 @@ def test_preload_with_available_records_queries_when_collection
13191319
end
13201320

13211321
assert_predicate post.association(:comments), :loaded?
1322-
assert_empty post.comments.map(&:object_id) & comments.map(&:object_id)
1322+
assert_empty post.comments.map(&:__id__) & comments.map(&:__id__)
13231323
end
13241324

13251325
def test_preload_with_available_records_queries_when_incomplete

0 commit comments

Comments
 (0)