Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

paginate_by_sql throwing error

#60

Trying to use paginate_by_sql and am getting an error. I have followed the example in finder.rb and have put the following in my controller:

def list
@contacts = Contact.paginate_by_sql ['SELECT * FROM contacts WHERE customer_id = ?', 2],
:per_page => 2, :page => params[:page], :total_entries => 3,
:order => 'name'
end

but whenever I try to view the page I get the following error:

DBI::DatabaseError in ContactsController#list

Not enough SQL parameters

I have attached the full error.

Reported by Mark Booth · July 15th, 2007 @ 02:32 PM

State: resolved
Milestone: none
Assigned to: Mislav Mislav

Activity

  1. Mark Booth
    Mark Booth

    Probably should have mentioned that this is on Windows and using MS SQL as the database.

    July 15th, 2007 @ 02:32 PM

  2. Chris Wanstrath
    Chris Wanstrath
    • State changed from new to open
    • Assigned user changed from Chris Wanstrath to Mislav

    July 15th, 2007 @ 02:32 PM

  3. Chris Wanstrath
    Chris Wanstrath
    • State changed from open to resolved

    (from [299]) Will Paginate: in paginate_by_sql, do sanitize_sql before calling add_limit on the query string. This is because of SQL Sever adapter which does nasty hacks in add_limit_offset and it needs a full SQL string for that. Added a bang on wp_parse_options method, also. [Mark Booth] [#60 state:resolved]

    http://require.errtheblog.com/pl...

    July 15th, 2007 @ 02:32 PM

  4. Mislav
    Mislav

    Thanks for the stack trace, it helped a lot. Otherwise I'd bang my head to the keyboard for hours.

    I've worked around your problem which happened because sqlserver_adapter does some really nasty hacks here. It should resolve the issue; if it does not, please reopen this ticket with additional information. Thanks

    July 15th, 2007 @ 02:32 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.