I’ve been using the composite_primary_keys gem in my Rails applications for quite some time, particularly for defining relationships with composite keys in a clean and efficient way. With the gem’s success since 2006 and its adaptability with various Rails versions, I’m starting to wonder about the broader community’s thoughts on its integration.
Is there a consensus within the Rails community on the inclusion of composite primary keys as a core feature, leveraging the well-maintained composite_primary_keys gem? What might be the pros and cons of such integration, especially considering use-cases like join-table entities? How do others approach composite keys in their Rails applications without this gem?
Composite Primary keys are will be part of Rails in 7.1. We didn’t use the gem because as an Rails extension this gem is not as well integrated with the framework as it could be. The gem was basically monkey patching Rails internals, which Rails itself should not be doing.
API should be compatible.
I’m not sure if all features are implemented, so if you could give a try in the 7.1 feature and report back any missing features that would be great.
Thank you for pointing out the inclusion of Composite Primary keys in Rails 7.1. It’s indeed an exciting update. I totally understand the hesitation with the gem. Using gems that monkey patch Rails internals can sometimes lead to unpredictable behaviors, and it’s always better if such features come integrated with the framework itself.
I also check this - https://www.reddit.com/r/rails/comments/ztctwt/does_rails_7_support_composite_primary_key/?rdt=53711
Regarding the API, it’s good to know that it should be compatible. As for the completeness of the features, I’ll definitely take a closer look at the Rails 7.1 feature and test its functionality. I appreciate the heads-up and will report back if I notice any missing elements or encounter issues.