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

Error when a relation with the name options exists. #675

Open
dhnaranjo opened this issue Mar 24, 2022 · 2 comments
Open

Error when a relation with the name options exists. #675

dhnaranjo opened this issue Mar 24, 2022 · 2 comments

Comments

@dhnaranjo
Copy link

dhnaranjo commented Mar 24, 2022

Describe the bug

When a relation with the name options exists the following error is raised when you create an instance of it:

rom-core-5.2.6/lib/rom/schema.rb:232:in `[]': :struct_namespace attribute doesn't exist in options schema (KeyError)

This happens because ROM::Initializer::InstanceMethods#options is called at either ROM::Relation#struct_namespace or ROM::Relation#meta_ast.

To Reproduce

require "rom"
require "dry-types"

rom = ROM.container(:memory, 'memory://test') do |config|
  config.relation(:options) do
    schema do
      attribute :whatever, Dry::Types["string"]
    end
  end
end

options = rom.relations[:options]
options.changeset(:create, whatever: "who cares").commit

Expected behavior

A relation named options doesn't poop my app

My environment

  • Affects my production application: No in that we're not yet in production, but yes this impacts real job stuff.
  • Ruby version: 3.1.1
  • OS: MacOS 12.whatever on an Apple Silicon device.
@dhnaranjo
Copy link
Author

Cool thing about being pre-launch is I just went and changed the table name, so I'm not urgently awaiting a fix or nothing.

@solnic
Copy link
Member

solnic commented Mar 25, 2022

Thanks for reporting this. It's been on my radar as it's a general issue of having reserved names that cannot be used as relation names. This will be properly addressed in 6.0.

@solnic solnic added this to the 6.0.0 milestone Mar 25, 2022
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