Fix many_to_many when one of the models has a prefix to the intersection model association#449
Fix many_to_many when one of the models has a prefix to the intersection model association#449jkeen merged 9 commits into
Conversation
…a prefix to the intersection model.
class Hc::Validator < ApplicationRecord
has_many :validator_universes
has_many :universes, through: :validator_universes, inverse_of: :hc_validators
end
class Hc::ValidatorResource < ApplicationResource
many_to_many :universes, resource: UniverseResource, foreign_key: { hc_validator_universes: :validator_id }
end
class Hc::ValidatorUniverse < ApplicationRecord
belongs_to :validator
belongs_to :universe
end
class Universe < ApplicationRecord
has_many :hc_validator_universes, class_name: 'Hc::ValidatorUniverse'
has_many :hc_validators, class_name: 'Hc::Validator', through: :hc_validator_universes, source: :validator
end
class UniverseResource < ApplicationResource
many_to_many :hc_validators, resource: Hc::ValidatorResource, foreign_key: { validator_universes: :universe_id }
end
|
@bguban Mind adding a test for this? I'm not quite understanding the issue |
|
Hi @jkeen. sorry for the late response. the problem is pretty simple. graphiti fails with when I make a request like Honestly say it's not clear why it takes |
|
Hi @jkeen, I've added tests. Not sure about the models (Stocks and Shop) so if you can find better names/meanings for the models and the namespace let me know. |
|
@jkeen have you had a chance to take a look at this PR? I'm not sure if the model names make good sense. I had to create a test when resources from different namespaces communicate via |
|
It looks like there just a few linter issues to resolve before this is good. I don't quite connect the stocks/shops model names as you mentioned, but at the moment I can't think of something better 🤔 |
## [1.7.8](v1.7.7...v1.7.8) (2025-03-16) ### Bug Fixes * compare URI-decoded path params ([#482](#482)) ([20b80dd](20b80dd)) * correct issue with many_to_many when one of the models has a prefix to the intersection model association ([#449](#449)) ([dc28a4f](dc28a4f)) * lazy constantize relation resources ([#492](#492)) ([3cc2983](3cc2983))
|
🎉 This PR is included in version 1.7.8 🎉 The release is available on:
Your semantic-release bot 📦🚀 |
Fix many_to_many when one of the models is under a namespace and has a prefix to the intersection model association.