rom-rb / rom-yesql

rom-rb adapter inspired by original Yesql from the Clojure world
http://rom-rb.org
MIT License
32 stars 6 forks source link

Undefined local variable or method opts using rom-yesql #10

Closed mrship closed 7 years ago

mrship commented 7 years ago

I'm trying to use rom-yesql alongside rom-sql and receive an error when auto-registering a relation.

My setup is something like this:

db_connection =  [default: [:sql, "sqlite::memory/store"],  container: [:yesql, "sqlite::memory/container", path: path]]

ROM.container(*db_connection) do |container|
  container.auto_registration(__dir__)
end

# in my relations folder
class OpportunityValue < ROM::Relation[:yesql]
  gateway :container
end

In running that setup, I get an error:

NameError: undefined local variable or method `opts' for #<ROM::Yesql::Dataset:0x007fa1973c9c00>
  /Users/shipmana/.rbenv/versions/2.2.5/lib/ruby/gems/2.2.0/gems/rom-sql-0.9.0/lib/rom/sql/relation.rb:52:in `block (2 levels) in inherited'

I'm not sure why the registration for the yesql relation is in the sql/relation code, but could it be that rom-yesql is not compatible with rom 2.20 and rom-sql 0.9.0 in some way?

solnic commented 7 years ago

It looks like yesql relations are being registered for sql adapter, did you set gateway to :container in yesql relation classes?

mrship commented 7 years ago

I had, as above, but your comment made me realise that I had other relations using the container gateway that were set to ROM::Relation[:sql], so I had a mixture of correctly setup and incorrectly setup relations. Thanks for the help; I'll close this now :)