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

Search Schema by field and field in the assoc #82

Open
duartepbrandao opened this issue Oct 12, 2018 · 4 comments
Open

Search Schema by field and field in the assoc #82

duartepbrandao opened this issue Oct 12, 2018 · 4 comments

Comments

@duartepbrandao
Copy link

duartepbrandao commented Oct 12, 2018

Hello.

Is it possible to search for both a field and a field from the assoc of the schema.
For example, using the phoenix_example(v2) project, searching for all the products where the category_name = "fic" and the product_name = "the" ?

I am sending these rummage_params:

params: %{
  paginate: %{page: 1, per_page: 5},
  search: %{
    category_name: "fic",
    internal_code: %{search_term: "", search_type: :ilike},
    name: %{search_term: "the", search_type: :ilike}
  }
}

but the query it creates its this one (columns removed for readability) :

SELECT * FROM (SELECT * FROM (SELECT * FROM "products" AS p0) AS s0
WHERE (s0."internal_code" ILIKE $1)) AS s0 WHERE (s0."name" ILIKE $2) 
LIMIT $3 OFFSET $4 ["%%", "%the%", 5, 0]

If this is not possible, can you point me in the direction for doing a PR for this functionality.

Thanks

@duartepbrandao duartepbrandao changed the title Search by field and assoc Search by field and field in the assoc Oct 12, 2018
@duartepbrandao duartepbrandao changed the title Search by field and field in the assoc Search Schema by field and field in the assoc Oct 12, 2018
@thebugcatcher
Copy link
Contributor

Hi @duartepbrandao, At this point, no. There will need to be a bigger change in rummage_ecto for this to work. The search hook needs to accept inputs in a different format. I think enough people have requested this feature, so I think maybe we should add this to 2.0 release!

What do you think @ericsullivan?

@ericsullivan
Copy link
Contributor

I think it's important enough to get it into the 2.0 release

@thebugcatcher
Copy link
Contributor

Cool! I will add it to the queue then!

@duartepbrandao
Copy link
Author

I have actually got it working tinkering with the rummage_scope and using the custom search.

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