Wrap plus combine fails
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
調査の方向性
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 の本文から書いたものです。
説明
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 はありません
環境構築
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rom-rb/rom-sql のほかの issue
-
bug help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
-
bug help wanted
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
bug help wanted
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
-
bug help wanted
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
-
bug help wanted
難易度 3/5 1〜2日 初心者へのやさしさ 45/100
似ている issue
-
account: profile
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 5 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
bug good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
ysb3996-blip/oops#24 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信