Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PG::UndefinedFunction: ERROR: could not identify an equality operator #391

Closed
mmahalwy opened this issue Jun 19, 2014 · 1 comment
Closed

Comments

@mmahalwy
Copy link

Kept running into this error and didn't know why. Finally figured it's this gem's problem.
Getting this error when calling total entries or just looping through @profiles

PG::UndefinedFunction: ERROR:  could not identify an equality operator for type profiles
LINE 1: SELECT COUNT(DISTINCT profiles.*) AS count_profiles_all, pro...
                              ^
: SELECT COUNT(DISTINCT profiles.*) AS count_profiles_all, profiles.id, profiles.email AS profiles_id_profiles_email FROM "profiles" LEFT OUTER JOIN "tags" ON "tags"."profile_id" = "profiles"."id" INNER JOIN "integration_profiles" ON "profiles"."id" = "integration_profiles"."profile_id" WHERE "integration_profiles"."integration_id" = $1 AND (("tags"."tag_name" ILIKE '%toronto%')) AND "profiles"."found" = 't' GROUP BY profiles.id, profiles.email

Currently I have model:

class Integration < ActiveRecord::Base
    belongs_to :user
    has_many :integration_profiles
    has_many :profiles, through: :integration_profiles
end

class Profile < ActiveRecord::Base
    has_many :integration_profiles
    has_many :integrations, through: :integration_profiles

    has_many :users, through: :integrations
    belongs_to :api_client

    has_many :tags
end

class Tag < ActiveRecord::Base
  belongs_to :user
  belongs_to :profile
end

In my IntegrationController

def show
  @integration = current_user.integrations.find(params[:id])
  @q = @integration.profiles.search(search_params)
  @profiles = @q.result.where(found: true).select("profiles.*").group("profiles.id, profiles.email").includes(:integration_profiles).order("CAST( translate(meta_data -> '#{params[:sort_by]}', ',', '') AS INT) DESC NULLS LAST")
end

It fails everytime but with some work in console, I found if I add .count("profiles.id") makes the count work. So I had to patch and do add at the end of my show action:

@profiles = @profiles.paginate(page: params[:page], per_page: 20, total_entries: @profiles.count("profiles.id").keys.count)`
@mislav
Copy link
Owner

mislav commented Jun 20, 2014

Likely fixed by #372 just the other day. No release yet, though. Can you temporarily upgrade will_paginate in your Gemfile to version from git master branch and see if it goes away?

@mislav mislav closed this as completed May 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants