You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. 👋 I ran into an issue that tripped me up due the error being rather confusing to debug:
rom-core-5.3.0/lib/rom/registry.rb:91:in `block in fetch': :account doesn't exist in ROM::AssociationSet[:integrations] registry (ROM::ElementNotFoundError)
In hindsight, the error makes a bit more sense now but when seeing it for the first time it took a while to realize that multiple association blocks won't work (which was an accident on my part due to being too hasty).
To Reproduce
Here's the inline script I used to reproduce (extracted from my Hanami application):
Script
#! /usr/bin/env ruby# frozen_string_literal: true# Save as `snippet`, then `chmod 755 snippet`, and run as `./snippet`.require"bundler/inline"gemfiletruedosource"https://rubygems.org"gem"amazing_print"gem"debug"gem"pg"gem"rom"gem"rom-sql"gem"sequel"endclassAccount < ROM::Relation[:sql]schema:accounts,infer: trueendclassProvider < ROM::Relation[:sql]schema:providers,infer: trueendclassIntegration < ROM::Relation[:sql]schema:integrations,infer: truedoassociations{belongs_to:account}associations{belongs_to:provider}endendconfiguration=ROM::Configuration.new:sql,"<redacted>"[Account,Provider,Integration].each{ |relation| configuration.register_relationrelation}container=ROM.containerconfigurationrepository=ROM::Repository.newcontainerputsrepository.integrations.combine(:account).to_a.inspect
Error
```
/Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/registry.rb:91:in `block in fetch': :account doesn't exist in ROM::AssociationSet[:integrations] registry (ROM::ElementNotFoundError)
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/registry.rb:88:in `fetch'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/registry.rb:88:in `fetch'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:288:in `node'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/support/memoizable.rb:50:in `block (2 levels) in define_memoizable_names!'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:271:in `block in nodes'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:268:in `each'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:268:in `reduce'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:268:in `nodes'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:252:in `combine'
from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/support/memoizable.rb:50:in `block (2 levels) in define_memoizable_names!'
from /Users/bkuhlmann/Engineering/Misc/snippet:43:in `'
```
Expected behavior
I guess I would have expected to see an error like "multiple association blocks detected, there can be only one" or something along those lines. 😅
Describe the bug
Hello. 👋 I ran into an issue that tripped me up due the error being rather confusing to debug:
In hindsight, the error makes a bit more sense now but when seeing it for the first time it took a while to realize that multiple association blocks won't work (which was an accident on my part due to being too hasty).
To Reproduce
Here's the inline script I used to reproduce (extracted from my Hanami application):
Script
Error
``` /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/registry.rb:91:in `block in fetch': :account doesn't exist in ROM::AssociationSet[:integrations] registry (ROM::ElementNotFoundError) from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/registry.rb:88:in `fetch' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/registry.rb:88:in `fetch' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:288:in `node' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/support/memoizable.rb:50:in `block (2 levels) in define_memoizable_names!' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:271:in `block in nodes' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:268:in `each' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:268:in `reduce' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:268:in `nodes' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/relation.rb:252:in `combine' from /Users/bkuhlmann/.cache/frum/versions/3.2.1/lib/ruby/gems/3.2.0/gems/rom-core-5.3.0/lib/rom/support/memoizable.rb:50:in `block (2 levels) in define_memoizable_names!' from /Users/bkuhlmann/Engineering/Misc/snippet:43:in `' ```Expected behavior
I guess I would have expected to see an error like "multiple association blocks detected, there can be only one" or something along those lines. 😅
The solution is to use:
Instead of:
Maybe if multiple
association
blocks are detected, a better error could be provided? This isn't a huge priority but more of a nice to have I suppose.My environment
The text was updated successfully, but these errors were encountered: