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

Broken String filter when filtering over multiple relations #62

Open
mikemix opened this issue Jul 15, 2020 · 0 comments
Open

Broken String filter when filtering over multiple relations #62

mikemix opened this issue Jul 15, 2020 · 0 comments
Labels
Bug Confirmed bugs or bugfixes.

Comments

@mikemix
Copy link

mikemix commented Jul 15, 2020

Description
Grid string filter doesn't work properly when filtering by multiple relations. The expression builder joins foreign relations using an INNER JOIN – if any relation is missing, nothing will be returned. The filter would work correctly if LEFT JOIN was used.

Steps to reproduce
Filter by multiple fields, eg. in the order admin of the Sylius framework:

      filters:
        customer:
          type: string
          label: sylius.ui.customer
          options: {fields: [customer.user.email, customer.defaultAddress.company]}

Generated SQL query (pseudo code):

SELECT * FROM sylius_customer c
INNER JOIN sylius_shop_user u ON c.id = u.customer_id
INNER JOIN sylius_address a ON a.id = c.default_address_id
WHERE (u.email LIKE '%value%' OR a.company LIKE '%value%')
  • Filtering by existing customer e-mail won't work if the customer has no default address.
  • Filtering by valid company name won't work if the customer has no user

Possible Solution
Use LEFT JOINs, let WHERE statements do their job.

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

No branches or pull requests

2 participants