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

Using OR instead of AND in the association #129

Open
undjike opened this issue Nov 25, 2021 · 6 comments
Open

Using OR instead of AND in the association #129

undjike opened this issue Nov 25, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@undjike
Copy link

undjike commented Nov 25, 2021

Please, is it possible to use OR in the association?

foreing_key_1 = local_key_1 OR foreing_key_2 = local_key_2
@undjike
Copy link
Author

undjike commented Nov 25, 2021

Pls, need help 🙏

@undjike
Copy link
Author

undjike commented Nov 30, 2021

@topclaudy, what about this?

@topclaudy
Copy link
Owner

@undjike Some people have requested different association logics. Can you please explain the use case(s) for this?

@undjike
Copy link
Author

undjike commented Nov 30, 2021

OK, let me explain.
I have a transaction table with some fields

  • id
  • type (withdraw or deposit)
  • amount
  • etc

When we have a transfer, both deposit and withdrawal are performed in the accounts concerned by the operation.
So, this is the structure of the transfer table...

  • id
  • withdraw_id
  • deposit_id
  • fees
  • etc

Then, when I'm to retrieve (with eager loading) the transfer associated to a transaction, I have to join using transaction.id = transfer.withdraw_id or transaction.id = transfer.deposit_id.

That's the point.

@topclaudy
Copy link
Owner

@undjike Thanks for the explanation. Please check discussion on #76 and #67. Such features are not on the roadmap.

@topclaudy topclaudy added the enhancement New feature or request label Jul 19, 2022
@neacon-ivalkenburg
Copy link

neacon-ivalkenburg commented May 8, 2023

Would really like to be able to use OR. But i can see why it could be a pain to add due to associating models.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants