You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In a Rails 4 app, there is the built-in option to use UUID the primary key in postgresql. It is possible to modify the migration template generated in order to support UUID primary keys. However, the function tagged_with breaks, because the primary key is hardcoded and presumed to be an integer in the following SQL queries:
joins << "JOIN #{ActsAsTaggableOn::Tagging.table_name}" +
" ON #{ActsAsTaggableOn::Tagging.table_name}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
" AND #{ActsAsTaggableOn::Tagging.table_name}.taggable_type = #{quote_value(base_class.name)}" +
" AND #{ActsAsTaggableOn::Tagging.table_name}.tagger_id = #{owned_by.id}" +
" AND #{ActsAsTaggableOn::Tagging.table_name}.tagger_type = #{quote_value(owned_by.class.base_class.to_s)}"
and
conditions << tags.map{ |t| "#{taggings_alias}.tag_id = #{t.id}"}.join(" OR ")
and finally
tagging_join="JOIN #{ActsAsTaggableOn::Tagging.table_name}#{taggings_alias}" +
" ON #{taggings_alias}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
" AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}" +
" AND #{taggings_alias}.tag_id = #{tag.id}"
Basically anything that contains #{something.id} will not work. There might be more, I'm not sure. I did a search for the string "id}" and these three came up. Because there are no quotes around the ID (assumed integer), the query breaks when the primary key is actually the UUID type and the quotes are needed.
Edit: formatting.
The text was updated successfully, but these errors were encountered:
In a Rails 4 app, there is the built-in option to use UUID the primary key in postgresql. It is possible to modify the migration template generated in order to support UUID primary keys. However, the function
tagged_with
breaks, because the primary key is hardcoded and presumed to be an integer in the following SQL queries:and
and finally
Basically anything that contains
#{something.id}
will not work. There might be more, I'm not sure. I did a search for the string"id}"
and these three came up. Because there are no quotes around the ID (assumed integer), the query breaks when the primary key is actually the UUID type and the quotes are needed.Edit: formatting.
The text was updated successfully, but these errors were encountered: