On Aug 5, 4:18 am, Aaron Pfeifer <[email protected]> wrote: > 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/misc.rb:123:in > `to_s' > > /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/misc.rb:123:in > `hash' > > /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/misc.rb:123:in > `sort_by' > > /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/misc.rb:123:in > `each' > > /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/misc.rb:123:in > `sort_by' > > /.rvm/gems/ruby-1.8.7-p334@sq3200/gems/sequel-3.20.0/lib/sequel/dataset/misc.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: class FooBar < Sequel::Model(Sequel::SQL::Identifier.new(:foo__bar)) end You'll need to update to the latest version of Sequel, as I'm pretty sure 3.20.0 doesn't support that. 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. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
