On Saturday, October 4, 2014 1:48:02 PM UTC-7, Michael Porter wrote: > > Thanks. Is there a nice way to intelligently carve off populated models > from a direct query's results (assuming all columns are included in the > result)? This is of course assuming that there is no row duplication > created by a many relationship. I imagine there are quite a few potential > pitfalls, but I'd really like to push developers to encapsulate business > rules in models, as I'm attempting to restructure a rather messy haphazard > Perl application, so being able to populate models even when the result set > necessitates direct queries would be quite handy. If such a method doesn't > exist, what gotchas could you point out in populating and using a model > with existing values from a table, such as dirty checks, etc.? >
Unfortunately, I don't think there is an existing Sequel method that does exactly what you want. In terms of taking a result set that combines multiple models and separating it, that's what eager loading with eager_graph does. But I doubt you could reuse that, as it is too tied to eager loading. The graph_each plugin along with Dataset#graph is the older method to split a combined result set. You could probably use that along with custom SQL if you know what you are doing. Thanks, Jeremy -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk. For more options, visit https://groups.google.com/d/optout.
