Skip to content

select table_name.* is explicitly ignored #9

@jbgo

Description

@jbgo

I was using perry to model a query like select distinct table_name.* from..., but perry explicitly ignored by select statement. Why is this? I know there are possibly better ways to model this query (like using group by and having clauses), but it still seems like it should be supported.

> Model.select('distinct models.*').to_hash
 => {}

Instead, I would expect to see

> Model.select('distinct models.*').to_hash
 => {:select => 'models.*'}

The relevant code is in Perry::Relation#to_hash. The omission seems intentional, but the reasoning behind it escapes me.

      # TRP: If one of the select options contains a * than select options are ignored
      if select_values && !select_values.empty? && !select_values.any? { |val| val.to_s.match(/\*$/) }
        value = call_procs(select_values)
        hash.merge!(:select => value.uniq)
      end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions