Class: UnnestedInFilters::Rewriter::ValueTable
- Inherits:
-
Object
- Object
- UnnestedInFilters::Rewriter::ValueTable
- Defined in:
- lib/unnested_in_filters/rewriter.rb
Instance Method Summary collapse
- #as_predicate ⇒ Object
-
#initialize(model, attribute, values) ⇒ ValueTable
constructor
A new instance of ValueTable.
- #to_sql ⇒ Object
Constructor Details
#initialize(model, attribute, values) ⇒ ValueTable
Returns a new instance of ValueTable.
9 10 11 12 13 |
# File 'lib/unnested_in_filters/rewriter.rb', line 9 def initialize(model, attribute, values) @model = model @attribute = attribute.to_s @values = values end |
Instance Method Details
#as_predicate ⇒ Object
19 20 21 |
# File 'lib/unnested_in_filters/rewriter.rb', line 19 def as_predicate "#{model.table_name}.#{column_name} = #{table_name}.#{column_name}" end |
#to_sql ⇒ Object
15 16 17 |
# File 'lib/unnested_in_filters/rewriter.rb', line 15 def to_sql "unnest(#{serialized_values}::#{sql_type}[]) AS #{table_name}(#{column_name})" end |