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

Unable to modify the node of a combined assc. when a child of that assc. is combined. #676

Open
dhnaranjo opened this issue Mar 28, 2022 · 0 comments

Comments

@dhnaranjo
Copy link

dhnaranjo commented Mar 28, 2022

Describe the bug

When using nested combine you are unable to modify the node of the first level of nesting. This ones is best explained by the script, but there's a fair amount of setup. The juicy part:

arel.combine(bbb: :ccc).node(:bbb) { _1.select(:id) }
# => wrong argument type Symbol (expected Array)

To Reproduce

require "rom"
require "rom-sql"
require "dry-types"
require "sqlite3"

rom = ROM.container(:sql, 'sqlite::memory') do |config|
  config.default.create_table(:cccs) do
    primary_key :id
  end
  config.default.create_table(:bbbs) do
    primary_key :id
    Integer :ccc_id
  end
  config.default.create_table(:aaas) do
    primary_key :id
    Integer :bbb_id
  end
  config.relation(:cccs) do
    schema do
      attribute :id, Dry::Types["integer"]
      primary_key :id
    end
  end
  config.relation(:bbbs) do
    schema do
      attribute :id, Dry::Types["integer"]
      primary_key :id
      attribute :ccc_id, Dry::Types["integer"]

      associations do
        belongs_to :ccc
      end
    end
  end
  config.relation(:aaas) do
    schema do
      attribute :id, Dry::Types["integer"]
      primary_key :id
      attribute :bbb_id, Dry::Types["integer"]

      associations do
        belongs_to :bbb
      end
    end
  end
end

arel = rom.relations[:aaas]
brel = rom.relations[:bbbs]
crel = rom.relations[:cccs]

brel.changeset(:create, id: 1).commit
crel.changeset(:create, id: 1).commit
arel.changeset(:create, bbb_id: 1, ccc_id: 1).commit

arel.combine(bbb: :ccc).node(:bbb) { _1.select(:id) }
# => wrong argument type Symbol (expected Array)

Expected behavior

I can work with the first level node.

My environment

  • Affects my production application: no
  • Ruby version: 3.1.1
  • OS: M1 Mac
@solnic solnic added this to the 6.0.0 milestone May 26, 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