Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Paginating a has_many :through with :uniq => true breaks under PostgreSQL #24

Closed
bloopletech opened this Issue Jan 13, 2010 · 5 comments

Comments

Projects
None yet
6 participants

Given a has_many :through with :uniq => true set, attempting to paginate the relationship will raise the error "could not identify an equality operator for type" under PostgreSQL.

The Finder class in WillPaginate has this line:

      if options[:select].gsub('`', '') =~ /\w+\.\*/

The gsub is supposed to remove the quoting from the sql fragment, but PostgreSQL uses " as the quote operator for table/column names. Changing this line to:

      if options[:select].gsub(/[`""]/m, '') =~ /\w+\.\*/

Fixes the problem.

pond commented Apr 21, 2010

I see this too and have locally patched my v2.3.12 gem as described above successfully, FWIW.

sphogan commented May 4, 2010

Square brackets ([]) need to be added to the regexp for SQL Server (and escaped in the regexp).

Contributor

kjg commented Jul 6, 2010

I have implemented bloopletech's fix along with a test at celect/will_paginate

Owner

mislav commented Jul 7, 2010

fixed in 470dae1, thanks

gruban commented Sep 30, 2010

The issue still exists for Rails 3.0

egiblin pushed a commit to egiblin/will_paginate that referenced this issue Feb 22, 2017

This issue was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment