mbleigh / acts-as-taggable-on

A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
MIT License
4.98k stars 1.19k forks source link

Sql error when taggable ActiveRecord model which has a non-integer primary key #915

Open herohhnparaiso opened 6 years ago

herohhnparaiso commented 6 years ago

To reproduce this, place an acts_as_taggable in an ActiveRecord that has a varchar as the primary key, then call Model.tagged_with("whatever").count

SELECT COUNT() FROM "features" INNER JOIN "taggings" "feature_taggings_23f3fd7" ON "feature_taggings_23f3fd7"."taggable_id" = "features"."key" AND "feature_taggings_23f3fd7"."taggable_type" = 'Feature' AND "feature_taggings_23f3fd7"."tag_id" IN (SELECT "tags"."id" FROM "tags" WHERE LOWER("tags"."name") ILIKE 'portal' ESCAPE '!') ActiveRecord::StatementInvalid: PG::UndefinedFunction: ERROR: operator does not exist: integer = character varying LINE 1: ...3fd7" ON "feature_taggings_23f3fd7"."taggable_id" = "feature... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. : SELECT COUNT() FROM "features" INNER JOIN "taggings" "feature_taggings_23f3fd7" ON "feature_taggings_23f3fd7"."taggable_id" = "features"."key" AND "feature_taggings_23f3fd7"."taggable_type" = 'Feature' AND "feature_taggings_23f3fd7"."tag_id" IN (SELECT "tags"."id" FROM "tags" WHERE LOWER("tags"."name") ILIKE 'portal' ESCAPE '!')