Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #240 from fschwahn/master

Postgres fix for tagged_with #2
  • Loading branch information...
commit d288663cc800f64e009abc6007798bd607e934f3 2 parents ef93e7f + afadfb1
@artemk artemk authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 lib/acts_as_taggable_on/acts_as_taggable_on/core.rb
View
7 lib/acts_as_taggable_on/acts_as_taggable_on/core.rb
@@ -90,6 +90,7 @@ def tagged_with(tags, options = {})
context = options.delete(:on)
owned_by = options.delete(:owned_by)
alias_base_name = undecorated_table_name.gsub('.','_')
+ quote = ActsAsTaggableOn::Tag.using_postgresql? ? '"' : ''
if options.delete(:exclude)
if options.delete(:wild)
@@ -119,7 +120,7 @@ def tagged_with(tags, options = {})
)
tagging_join = "JOIN #{ActsAsTaggableOn::Tagging.table_name} #{taggings_alias}" +
- " ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key}" +
+ " ON #{taggings_alias}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
@Sija
Sija added a note

ActiveRecord::Base.connection.quote_table_name(table_name) might be your guy :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
" AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}"
tagging_join << " AND " + sanitize_sql(["#{taggings_alias}.context = ?", context.to_s]) if context
@@ -138,7 +139,7 @@ def tagged_with(tags, options = {})
taggings_alias = adjust_taggings_alias("#{alias_base_name[0..11]}_taggings_#{sha_prefix(tag.name)}")
tagging_join = "JOIN #{ActsAsTaggableOn::Tagging.table_name} #{taggings_alias}" +
- " ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key}" +
+ " 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}"
tagging_join << " AND " + sanitize_sql(["#{taggings_alias}.context = ?", context.to_s]) if context
@@ -160,7 +161,7 @@ def tagged_with(tags, options = {})
if options.delete(:match_all)
joins << "LEFT OUTER JOIN #{ActsAsTaggableOn::Tagging.table_name} #{taggings_alias}" +
- " ON #{taggings_alias}.taggable_id = #{table_name}.#{primary_key}" +
+ " ON #{taggings_alias}.taggable_id = #{quote}#{table_name}#{quote}.#{primary_key}" +
" AND #{taggings_alias}.taggable_type = #{quote_value(base_class.name)}"
Please sign in to comment.
Something went wrong with that request. Please try again.