splitwise / super_diff

A more helpful way to view differences between complex data structures in RSpec.
https://splitwise.github.io/super_diff/
MIT License
986 stars 53 forks source link

Support the use of primary keys other than "id" in ActiveRecord. #237

Closed benk-gc closed 6 months ago

benk-gc commented 7 months ago

Previously the diffing code made an assumption that "id" would always be the primary field. This is not always the case, and the use of read_attribute(:id) is deprecated in rails/rails@39997a0.

This changes adds support for use of custom primary key fields, and updates the Person test model to use the "person_id" primary key.

Note that this will almost certainly still run into issues if the model uses the newly introduced composite primary key type, so this would require additional changes outside the scope of this fix.

benk-gc commented 7 months ago

@mcmire Any chance you could approve the test workflow and give this one a look? This would unblock us using the gem in Rails 7.1. Thanks!

benk-gc commented 6 months ago

@mcmire Specs looks happy - what do you think about a merge + release for this one? Happy to make any changes.

benk-gc commented 6 months ago

@mcmire Ping on the above when you have a sec - thanks!

mcmire commented 6 months ago

I've released this under 0.12.0: https://github.com/mcmire/super_diff/releases/tag/v0.12.0. Thanks again!