lib/pg_search/configuration/column.rb in pg_search-0.5.1 vs lib/pg_search/configuration/column.rb in pg_search-0.5.2

- old
+ new

@@ -1,37 +1,38 @@ require 'digest' module PgSearch class Configuration class Column - attr_reader :weight, :association + attr_reader :weight - def initialize(column_name, weight, model, association = nil) + def initialize(column_name, weight, model) @column_name = column_name.to_s @weight = weight @model = model - @association = association + @connection = model.connection end - def table - foreign? ? @association.table_name : @model.table_name - end - def full_name - "#{@model.connection.quote_table_name(table)}.#{@model.connection.quote_column_name(@column_name)}" + "#{table_name}.#{column_name}" end def to_sql - name = if foreign? - "#{@association.subselect_alias}.#{self.alias}" - else - full_name - end - "coalesce(#{name}::text, '')" + "coalesce(#{expression}::text, '')" end - def foreign? - @association.present? + private + + def table_name + @connection.quote_table_name(@model.table_name) + end + + def column_name + @connection.quote_column_name(@column_name) + end + + def expression + full_name end def alias Configuration.alias(association.subselect_alias, @column_name) end