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

Limited query-ability. #88

Open
hickscorp opened this issue Aug 28, 2019 · 2 comments
Open

Limited query-ability. #88

hickscorp opened this issue Aug 28, 2019 · 2 comments

Comments

@hickscorp
Copy link

hickscorp commented Aug 28, 2019

If I want a query to return records for which the enum is either of two values, the following syntax should work:

Invitation
  |> where(type: ^[:expert, :investor])
  |> Repo.all 

I tried pretty much everything I could, it just simply doesn't work. I would have expected a type IN ... query to be generated, but it's not.

For now, the solution seems to be a or_where(...) construct, but it gets really messy with more constraints on other fields.

@gjaldon
Copy link
Owner

gjaldon commented Aug 29, 2019

Does this work?

  Invitation
  |> where([i], i.type in ^[:expert, :investor])
  |> Repo.all 

What kind of ecto_enum is this? Is it string-backed, integer-backed or does it use PG types?

@OvermindDL1
Copy link

|> where(type: ^[:expert, :investor])

Doesn't this form lose type information of what is being processed on the struct?

|> where([i], i.type in ^[:expert, :investor])

Where this style keeps type information (and thus ecto enum conversions)?

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