First off, sorry for all the posts, I'm trying to figure out how to
port a large XML/JSON app (>150 tables) from AR to Sequel.

I read thru the rdoc and saw some IRC chat on this, but the solutions
don't work from what I can tell.  It is possible I missed something.
Say I have this in AR:

   class Account < ActiveRecord::Base
      named_scope :active, :conditions => 'is_active = 1'
      named_scope :admin, :conditions => 'account_type_id = 3'
      named_scope :by_newest_reg, :order => 'registration_date desc'
   end

I can then chain them together and get all three combined:

   Account.admin.active.by_newest_reg

In the Sequel DSL that would be something like

   Account.filter( 'is_active = 1').filter('account_type_id = 3').order
(:registration_date.desc)

So I tried to port this over to Sequel by just defining some self.
methods in the model:

   class Account < Sequel::Model
      def self.active
         filter('is_active = 1')
      end
      def self.admin
         filter('account_type_id = 3')
      end
      def self.by_newest_reg
         order(:registration_date.desc)
      end
   end

And that works but only one deep, because the return from Model.find/
filter/etc is actually Dataset, not Model.  So these work:

   Account.active
   Account.admin
   Account.by_newest_reg

But not:

   Account.admin.active.by_newest_reg

Because the return is a different class, the only way I see that
working is if Model < Dataset which looks nontrivial.

I miss somthing obvious?

-Nate

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to