Pagination with eagerfindersql

I have installed the plugin eagerfindersql.

if i try to insert :limit and offset in find:
events=Event.find(:all, :limit=>10,:offset => 0,:include =>
[:event_type_names,{:event_dates => {:place => :locality}}],
:finder_sql => query,
:column_mapping => {…

this not works and show all elements.

if i try to insert limit in query. the events that returning are less of
10.

Beacuse all events have more event_dates.

How i can to use limit???

Thanks

On 10 Dec 2007, at 13:19, Luca R. wrote:

this not works and show all elements.

if i try to insert limit in query. the events that returning are
less of
10.

With the plugin, the sql that is used is the one passed via
the :finder_sql.
Just looking quickly at the plugin’s code, this suggests that it will
ignore the :limit and :offset you’re supplying.
You just have to write the whole query yourself (which is rather the
point of the plugin)

Fred

Frederick C. wrote:

On 10 Dec 2007, at 13:19, Luca R. wrote:

this not works and show all elements.

if i try to insert limit in query. the events that returning are
less of
10.

With the plugin, the sql that is used is the one passed via
the :finder_sql.
Just looking quickly at the plugin’s code, this suggests that it will
ignore the :limit and :offset you’re supplying.
You just have to write the whole query yourself (which is rather the
point of the plugin)

Fred

But if i insert limit in the finder_sql the number of the elements
selected are less of limit setted.

On 10 Dec 2007, at 14:42, Luca R. wrote:

With the plugin, the sql that is used is the one passed via
the :finder_sql.
Just looking quickly at the plugin’s code, this suggests that it will
ignore the :limit and :offset you’re supplying.
You just have to write the whole query yourself (which is rather the
point of the plugin)

Fred

But if i insert limit in the finder_sql the number of the elements
selected are less of limit setted.

You’re probably running into the fact that limiting and eager loading
don’t really mix. You’ll probably have to replicate what activerecord
does under the hood when you don’t use eagerfindersql:
1 query to determine which events to load (and get back from that the
ids to load), and a second query that loads them with the associations.

Fred

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs