rom-sql icon indicating copy to clipboard operation
rom-sql copied to clipboard

Undefining `by_pk` causes stack overflow in auto_curry

Open solnic opened this issue 6 years ago • 0 comments

Introduced in https://github.com/rom-rb/rom-sql/commit/869b46be

Steps to repro:

require 'rom'
require 'rom-sql'
require 'rom-repository'

module Relations
  class Users < ROM::Relation[:sql]
    schema(:users, infer: true)
  end
end

class UserRepository < ROM::Repository[:users]
  def find(uuid)
    users.by_pk(uuid).one
  end
end

def build_container(rom_base)
  config = ROM::Configuration.new(:sql, 'postgres://localhost/rom_test')
  config.register_relation(Relations::Users)
  ROM.container(config)
end

rom_base = ROM::Configuration.new(:sql, 'postgres://localhost/rom_test')

5.times do
  rom = build_container(rom_base)
  repo = UserRepository.new(rom)
  repo.find(1)
  rom.disconnect
  puts "\n"
end

solnic avatar Oct 04 '18 07:10 solnic