Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

Wrap plus combine fails

オープン
#295 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
ruby, sql, sqlite
領域
backend, databases

調査の方向性

Start by running the inline Ruby reproduction and compare the working two-combines query with wrap_and_combine. The reported failure is in rom-core-4.2.1/lib/rom/relation/combined.rb at line 21; done means wrap followed by combine no longer raises ArgumentError and returns the combined result shown by the repro.

索引モデルが issue の本文から書いたものです。

説明

bug help wanted

I have an issue where using wrap and combine together causes the error:

 wrong number of arguments (given 3, expected 2) (ArgumentError)

However, if I use two combines, then it works as expected. A repro script is inlined below.
This is slightly complicated because the relationship for manager is on the same table, but I have this elsewhere as well with more "standard" table relationships.


#!/usr/bin/env ruby
require 'bundler/inline'

gemfile do
  source 'https://rubygems.org'
  gem 'rom'
  gem 'rom-sql'
  gem 'rom-repository'
  gem 'dry-types'
  gem 'sqlite3'
end

require 'rom-sql'
require 'rom-repository'
require 'rom/transformer'
require 'dry-types'

module Types
  include Dry::Types.module
end

rom = ROM.container(:sql, 'sqlite::memory') do |c|
  c.gateways[:default].create_table :active_directory do
    column :mail, String
    column :name, String
    column :gwereportingto, String
  end

  c.gateways[:default].create_table :hierarchies do
    column :employee, String
    column :level, Integer
    column :no_of_reportees, String
  end

  c.gateways[:default].use_logger(Logger.new($stdout))

  c.relation(:hierarchies) do
    schema(:hierarchies, infer: false) do
      attribute :employee, Types::String.meta(primary_key: true)
      attribute :level, Types::Int
      attribute :no_of_reportees, Types::Int
    end
  end

  c.relation(:colleagues) do
    schema(:active_directory, infer: false, as: :colleagues) do
      attribute :mail, Types::String.meta(primary_key: true)
      attribute :name, Types::String
      attribute :gwereportingto, Types::String

      associations do
        belongs_to :hierarchy, foreign_key: :mail
        belongs_to :active_directory, relation: :colleagues, as: :manager, foreign_key: :gwereportingto
      end
    end
  end
end

jane = rom.relations[:colleagues].insert(mail: "[email protected]", name: "Jane")
fred = rom.relations[:colleagues].insert(mail: "[email protected]", name: "Fred", gwereportingto: "[email protected]")
rom.relations[:hierarchies].insert(employee: "[email protected]", no_of_reportees: 1, level: 2)

class ColleagueRepo < ROM::Repository[:colleagues]
  def wrap_and_combine
    colleagues
      .wrap(:hierarchies)
      .combine(:manager)
      .where(mail: "[email protected]")
      .where(level: 2)
      .one
  end

  def two_combines
    colleagues
      .join(:hierarchies)
      .combine(:hierarchy, :manager)
      .where(mail: "[email protected]")
      .where(level: 2)
      .one
  end
end

repo = ColleagueRepo.new(rom)

puts "------\n"
puts repo.two_combines.inspect
puts "------\n"
puts repo.wrap_and_combine.inspect

#<ROM::Struct::Colleague mail="[email protected]" name="Fred" gwereportingto="[email protected]" hierarchy=#<ROM::Struct::Hierarchy employee="[email protected]" level=2 no_of_reportees="1"> manager=#<ROM::Struct::Manager mail="[email protected]" name="Jane" gwereportingto=nil>>
------
/Users/shipmana/.rbenv/versions/2.4.3/lib/ruby/gems/2.4.0/gems/rom-core-4.2.1/lib/rom/relation/combined.rb:21:in `new': wrong number of arguments (given 3, expected 2) (ArgumentError)
主要言語
Ruby
スター
220
フォーク
97
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rom-rb/rom-sql のほかの issue

rom-rb/rom-sql の issue をすべて見る

似ている issue

Ruby の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。