On Wednesday, April 17, 2019 at 6:23:49 AM UTC+9, Ryan Kingston wrote:
>
> I am using Sequel in a Rails view. If I call Sequel::Dataset#empty? twice 
> in the same view, it results in two queries to the database. Is this the 
> intended behavior or is there a way to have Sequel cache these kind of 
> values?
>

Sequel datasets do not cache calls that depend on database state, with the 
exception of the dataset's columns.  It wouldn't make sense, because there 
could have been changes in the database between the two calls.

To avoid this issue in the view, call the method once, store the result in 
a local variable, and use the local variable instead of calling the method 
again.

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