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

[BUG] Search for fields across associations #324

Open
anhnk opened this issue Dec 15, 2024 · 3 comments
Open

[BUG] Search for fields across associations #324

anhnk opened this issue Dec 15, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@anhnk
Copy link
Contributor

anhnk commented Dec 15, 2024

Versions Used
Kaffy: 0.10.3
Phoenix: 1.7.18
Elixir: 1.14.1

What's actually happening?

An error is raised when association is used in search fields. It looks like the query builder didn't use the association at all.

I've narrowed down to the code here in resource_query but couldn't make any further progress.

This is the error:

Postgrex.Error at GET /admin/user/post
ERROR 42703 (undefined_column) column p0.username does not exist

    query: SELECT p0."id", p0."user_id", p0."inserted_at", p0."updated_at" FROM "posts" AS p0 LEFT OUTER JOIN "users" AS u1 ON u1."id" = p0."user_id" WHERE (p0."username"::varchar ILIKE $1) ORDER BY p0."id" DESC LIMIT $2 OFFSET $3

    hint: Perhaps you meant to reference the column "u1.username".

This is my code:

defmodule Mode.Kaffy.PostAdmin do
   def search_fields(_schema) do
    [
      user: [:username]
    ]
  end

What should happen instead?

The Query builder should use association for search field with association.

Screenshots
If applicable, add screenshots to help explain your problem.

@anhnk anhnk added the bug Something isn't working label Dec 15, 2024
@anhnk
Copy link
Contributor Author

anhnk commented Dec 15, 2024

I downgraded to v0.10.2 and it worked. It's possible that the bug was introduced in this commit.

@ghenry
Copy link
Collaborator

ghenry commented Dec 15, 2024 via email

@anhnk
Copy link
Contributor Author

anhnk commented Dec 15, 2024

Thanks for the prompt response! I've created a PR.

Looking forward to pulling the latest version. Kaffy has been saving me lots of time. Huge kudos to the team!

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

No branches or pull requests

3 participants