On Nov 15, 4:00 pm, jdunphy <[EMAIL PROTECTED]> wrote:
> By the way.  This was a really dumb topic name.
>
> On Nov 15, 4:00 pm, jdunphy <[EMAIL PROTECTED]> wrote:
>
> > I'm transferring a set of ActiveRecord models over to Sequel::Model,
> > and everything has been running pretty smoothly.  The only hiccup I've
> > had has been with one find method that required a join.
>
> >http://pastie.org/315835
>
> > While this works as expected, I find some of the syntax a little
> > distressing, to perform the join, but prevent the results from getting
> > messed up in the response, I had to use a "string".lit in the select.
>
> > Rating.select("ratings.*".lit).left_outer_join
> > (RatedBusiness, :rating_id => :id)
>
> > While it works, it feels clunky to me.  Is there a more elegant/
> > standard way to acheive this end with a different syntax?  Nothing
> > jumped out at me.

The one thing to keep in mind is that you should rarely need to use
literal SQL strings in Sequel (though you can if you want).  Here's
how I would change your code to make it Sequelesque:

  dataset = Rating.select(:ratings.*).exclude(:suppressed => 1).
    order(:created_at.desc).left_outer_join(RatedBusiness, :rating_id
=> :id)
  dataset.filter!(:value >= options[:rating_limit]) if options
[:rating_limit]
  dataset.filter!(:rated_businesses__heading_code => Array(options
[:heading_codes])) if options[:heading_codes]

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

Reply via email to