On Apr 12, 10:09 am, Ciryus <[email protected]> wrote: > Using DataMapper I actually did a raw SQL query to get all my stats, > and used the result hash separately from my model. I could do exactly > the same with Sequel I'm sure.
You definitely could. That's pretty much what the associations stuff is doing internally. > What I'm looking at I guess, is a way to get "virtual attributes" > loaded along real ones when getting a dataset. Something like what > eager does. I'd like to write my own "eager" so that whenever I get a > bunch of Project objects, I then launch my own queries (even raw sql > on unrelated tables if that makes sense), and "add" the virtual > attributes to my objects. It should make it easy to add new virtual > attributes, or change them. I'll look more into the code of the eager > method to understand how it does it. Using the :dataset and :eager_loader options you should be able to get any sort of virtual attributes based on related tables. Advanced statistics may not always be possible via eager loading, but if it is possible at an SQL level, it should be possible with Sequel. I haven't produced any examples of using associations for statistics (other than the one in this thread), but if you want some other examples of advanced associations, see http://sequel.rubyforge.org/rdoc/files/doc/advanced_associations_rdoc.html. > I'm not an expert on Ruby ORM, but I must admit I really like Sequel > so far. Out of curiosity, I'm wrote the same application in Rails with > ActiveRecord, DataMapper and now Sequel. Sequel is really the most > powerful of the three, and also the more consistent in terms of > syntax. I'm really surprised it's not as talked about as the two > others. I'm really looking forward to its future. I haven't done a lot of promotion until recently, I've mostly worked on improving Sequel. Now that Sequel is a fairly mature library, I'm trying to get the word out by speaking at ruby conferences. The best way to help is to recommend Sequel to your fellow rubyists, via IRC, a blog, or some other medium. This thread is a good example of how Sequel is more powerful and still remains simple to use. > BTW, would you have links to articles or documentation explaining how > to write plugins for Sequel? Otherwise I'll just look at existing > plugins. There's not a lot of documentation right now, but creating a plugin is fairly straight forward (see http://sequel.rubyforge.org/rdoc/classes/Sequel/Plugins.html). If you look at the plugins that ship with Sequel, you should be able to get a good idea of what is possible. Generally, Sequel plugins are easy to write, since you just override whatever you want and call super to get the default behavior. If you have any questions, don't hesitate to ask. 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 -~----------~----~----~----~------~----~------~--~---
