Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relation with name `:schema' causes registration problems #615

Open
dchandekstark opened this issue Dec 17, 2020 · 0 comments
Open

Relation with name `:schema' causes registration problems #615

dchandekstark opened this issue Dec 17, 2020 · 0 comments
Assignees
Milestone

Comments

@dchandekstark
Copy link

dchandekstark commented Dec 17, 2020

Describe the bug

Non-aliased schema name :schema appears to cause relation registration problems.

To Reproduce

My relation has this configuration snippet:

schema(:schema) do
   ...
end

When I register the relation with a configuration, create a container with the config, then access the relation:

contianer.relations[:schema]

I get an error:

       16: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/setup/finalize.rb:88:in `load_relations'
       15: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/setup/finalize/finalize_relations.rb:32:in `run!'
       14: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/registry.rb:31:in `new'
       13: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/registry.rb:31:in `new'
       12: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/relation_registry.rb:11:in `initialize'
       11: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/setup/finalize/finalize_relations.rb:33:in `block in run!'
       10: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/setup/finalize/finalize_relations.rb:33:in `each'
        9: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/setup/finalize/finalize_relations.rb:50:in `block (2 levels) in run!'
        8: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/setup/finalize/finalize_relations.rb:108:in `build_relation'
        7: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/support/memoizable.rb:15:in `new'
        6: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/support/memoizable.rb:15:in `new'
        5: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/dry-initializer-3.0.4/lib/dry/initializer/mixin/root.rb:7:in `initialize'
        4: from (eval):18:in `__dry_initializer_initialize__'
        3: from (eval):18:in `instance_exec'
        2: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/relation.rb:154:in `block in <class:Relation>'
        1: from /Users/dc/.rvm/gems/ruby-2.6.5@solrbee/gems/rom-core-5.2.3/lib/rom/plugins/relation/registry_reader.rb:38:in `block (2 levels) in define_readers!'
NoMethodError (undefined method `[]' for nil:NilClass)

If I change the relation config to alias the name `:schema':

schema(:schema, as: :foo_schema) do
   ...
end

then

container.relations[:foo_schema]

works as expected.

Expected behavior

If :schema needs to be reserved, then registration should emit appropriate advice on failure, such as "cannot use name reserved name ':schema' in relation registry". Otherwise, registration would work as normal.

Your environment

  • Affects my production application: NO
  • Ruby version: 2.6.5
  • OS: MacOS Catalina 10.15.7
@solnic solnic added this to the 6.0.0 milestone Dec 18, 2020
@solnic solnic self-assigned this Jan 12, 2021
ippachi added a commit to ippachi/rom that referenced this issue May 28, 2021
solnic pushed a commit that referenced this issue Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Backlog
Development

No branches or pull requests

2 participants