On Thursday, March 27, 2014 2:03:16 PM UTC-7, Joel VanderWerf wrote: > > > Is there a way to construct a dataset without a database, and then later > associate the dataset with a database or even with several databases? > Something like this: > > ds = Dataset.new.select(...)... > > ds.on(db1).all > ds.on(db2).all >
No. Datasets are tied to the databases that created them, by design. The reason for this is because calling a dataset method can result in different dataset state depending on the database in use. The simplest example is Dataset#graph, but there are numerous other cases. If you want to throw caution to the wind: ds = Dataset.new.select(...)... db1.dataset.clone(ds.opts).all db2.dataset.clone(ds.opts).all The better solution is to have a proc that takes a database and returns the appropriate dataset for that database: ds_proc = proc do |db| db.dataset.select(...)... end ds_proc.call(db1).all ds_proc.call(db2).all 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.
