On Tuesday, April 21, 2020 at 6:08:47 AM UTC-7, shreko wrote: > > Thank you Jeremy, it works. Thanks for being patient with my lack of > knowledge in this matter. > > I am wondering if there may be a better way to query Eager relationships > in a way that would strip out Model thing and output just arrays of hashes > or to_hash_groups just like when calling .all on a dataset like > > DB["select * from jobs join job_items ..."].all >
You can use graph_each without using models: DB.extension(:graph_each) DB[:job].graph(:job_items, :job_id=>:id).all This gives you an array of hashes, and each hash has one key per table, with the values being a hash of values corresponding to the columns in that table. It's not as friendly as using models, though, because if you have a Job with 10 JobItems, you'll get 10 rows each with the same Job, instead of one row for the Job with the job_items associations set correctly. You are probably better off using models in this case. 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 view this discussion on the web visit https://groups.google.com/d/msgid/sequel-talk/e46c079d-43e0-4b01-842a-f2dc75c7e58e%40googlegroups.com.
