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

Identity.where is not working #305

Closed
jechol opened this issue May 27, 2024 · 3 comments
Closed

Identity.where is not working #305

jechol opened this issue May 27, 2024 · 3 comments
Labels
bug Something isn't working needs review

Comments

@jechol
Copy link
Contributor

jechol commented May 27, 2024

Describe the bug
The Identity.where option is being ignored.

To Reproduce

For example,

  identities do
    identity :foo_bar, [:foo], where: :bar_is_ten
  end

  postgres do
    identity_wheres_to_sql [bar_is_ten: "bar = 10",  
                            foo_bar: "bar = 20"]
  end

This results in bar_is_ten being ignored, and it creates the following with where: "bar = 20" instead:

  create unique_index(:my_table, ["foo"], name: "foo_bar_index", where: "bar = 20")

Expected behavior

A migration with "bar = 10"

 create unique_index(:my_table, ["foo"], name: "foo_bar_index", where: "bar = 10")
@jechol jechol added bug Something isn't working needs review labels May 27, 2024
@jechol jechol changed the title Identity.where is not working Identity.where is not working May 27, 2024
@zachdaniel
Copy link
Contributor

The way that you're writing it is incorrect. The key is the identity name and the value is the SQL where clause.

identities do
    identity :foo_bar, [:foo], where: expr(bar == 10)
  end

  postgres do
    identity_wheres_to_sql [foo_bar: "bar = 10"]
  end

@zachdaniel zachdaniel closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2024
@jechol
Copy link
Contributor Author

jechol commented May 28, 2024

@zachdaniel

So, the expression expr(bar == 10) in the where clause is not actually being used, right?

I'm just asking for confirmation. 😄

@zachdaniel
Copy link
Contributor

It's not being used to generate the filter in Postgres cases, no. (Because we don't have an expr -> raw SQL converter yet), it's all Ecto expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants