On Sunday, November 4, 2018 at 8:09:53 PM UTC-8, Artur Trofimov wrote:
>
> Hello, Jeremy!
>
> What if I need to return two records and then calculate an average for it?
>
> I used this way
> ds = Sequel.mock[:t].with_fetch([{:x=>1}, {:x=>3}])
> but ds.avg(:x) returns 1.
>
> Do I need to write a monkey patch for this method for my tests?
>

No, but you do need to do:

  ds.with_fetch(:v=>2).avg(:x)

Alternatively, you can pass with_fetch a proc.  The proc is called with the 
SQL, and can return the appropriate result based on the SQL.

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 https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to