Sha256: 6a30757a7b8bbd43733fc8123b127a2580012d0640ce3d139030e2fd49d2bc54

Contents?: true

Size: 569 Bytes

Versions: 3

Compression:

Stored size: 569 Bytes

Contents

module RecordFilter
  class GroupBy # :nodoc: all
    attr_reader :column, :table

    def initialize(column, table)
      @column, @table = column, table
    end

    def to_sql
      table, column = @table, @column
      while column.is_a?(Hash)
        table = table.join_association(column.keys[0]).right_table
        column = column.values[0]
      end

      if (!table.has_column(column))
        raise ColumnNotFoundException.new("The column #{column} was not found in #{table.table_name}.")
      end

      "#{table.table_alias}.#{column}"
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
aub-record_filter-0.8.0 lib/record_filter/group_by.rb
aub-record_filter-0.9.0 lib/record_filter/group_by.rb
outoftime-record_filter-0.8.0 lib/record_filter/group_by.rb