Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generator for attribute options #52

Open
anaice opened this issue Oct 11, 2019 · 3 comments
Open

generator for attribute options #52

anaice opened this issue Oct 11, 2019 · 3 comments

Comments

@anaice
Copy link
Contributor

anaice commented Oct 11, 2019

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.

@mrkamel
Copy link
Owner

mrkamel commented Oct 23, 2019

Hi, sry for the delayed response. Currently, it's not possible. I'm of course open for contributions, but i won't add it myself due to lack of time and i've no need for it.

@anaice
Copy link
Contributor Author

anaice commented Oct 28, 2019

Hi. Sorry for the delay here too. I understand your point. I'll study the code a bit and see if I can implement this.
Anyway, thanks for your time.

@westonganger
Copy link

I am going to try taking a stab at adding this functionality. Seems like a very useful feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants