> Hey guys -
> Prior to Sequel 3.20.0, I could do the following:
> class FooBar < Sequel::Model(DB[Sequel::SQL::Identifier.new(:foo__bar)])
> ...
> end
> This would allow me to create a model backed by a table that has double
> underscores in it. After 3.20.0, this causes the following error:
> ArgumentError: wrong number of arguments (0 for 1)
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
> `to_s'
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
> `hash'
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
> `sort_by'
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
> `each'
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
> `sort_by'
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/mis c.rb:123:in
> `hash'
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/model.rb:38 :in
> `[]'
> /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/model.rb:38 :in
> `Model'
> This is because the Sequel::Dataset instance has implemented a hash method
> which calls #to_s on its options hash. Since the Sequel::SQL::Identifier
> instance is in that options hash, it also has #to_s called on it. However,
> all expressions (including this identifier instance) override #to_s so that
> it requires a single argument being the Dataset.
> Given that context, is there a more appropriate way to creating models that
> are backed by tables with double underscores?
Assuming you are only using one Database object, just use:
However, the way you are currently doing it should work. The behavior
you are seeing is still present in the master branch. It's a bug and
will be fixed shortly.