I get the following error:
PGError: ERROR: operator does not exist: character varying >= integer LINE 1: ...CT "games".* FROM "games" WHERE ("games"."uuid" >= 0) ORDE... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. : SELECT "games".* FROM "games" WHERE ("games"."uuid" >= 0) ORDER BY "games"."uuid" ASC LIMIT 1000
when i try to do this:
Game.find_each do |game|
I have a primary string key (UUID) for my model:
class Game < ActiveRecord::Base self.primary_key = 'uuid' before_create do |game| game.uuid = UUIDTools::UUID.timestamp_create().to_s if game.uuid.blank? end end
I donβt know why ActiveRecord places a WHERE
in this WHERE
, but it is completely unnecessary and the reason is for a type error (since it is a string column, not an integer).
So how can I avoid this? Is this something I have to put in my model definition? Or should I avoid find_each
and use a different method? This is a rake task that just goes through all the records and looks for additional information ...
source share