Skip to content

generator for attribute options #52

@anaice

Description

@anaice

Hello @mrkamel

I was wondering if it would be possible to use a generator directly in the options of an attribute.

search_scope :search do
  attributes person: [ "person.full_name", "person.display_name", "person.doc_id"]
  options :person, left_wildcard: false
  attributes partner_doc_id: ["person.doc_id" ]
  options :partner_doc_id, raw_ilike: true

  #...

  generator :raw_ilike do |column_name, raw_value|
    "(  #{column_name} IS NOT NULL AND
       regexp_replace(#{column_name}, '[^a-zA-Z0-9]+', '','g') ILIKE ('%' || regexp_replace('#{raw_value}', '[^a-zA-Z0-9]+', '','g') || '%') 
      )
     "
  end
end

I know the generator is designed for hash based queries, but it would be a very useful feature to be able to apply it directly to an attribute.

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