#60 ✓resolved
Mark Booth

paginate_by_sql throwing error

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

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.

Comments and changes to this ticket

  • Mark Booth

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

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

  • Chris Wanstrath

    Chris Wanstrath July 15th, 2007 @ 02:32 PM

    • State changed from “new” to “open”
    • Assigned user changed from “Chris Wanstrath” to “Mislav”
  • Chris Wanstrath

    Chris Wanstrath July 15th, 2007 @ 02:32 PM

    • 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...

  • Mislav

    Mislav July 15th, 2007 @ 02:32 PM

    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

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.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Shared Ticket Bins

People watching this ticket

Attachments

Pages