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

OR needed in SELECT query #581

Open
briskt opened this issue Jan 24, 2020 · 2 comments
Open

OR needed in SELECT query #581

briskt opened this issue Jan 24, 2020 · 2 comments
Labels
f: sql about SQL support

Comments

@briskt
Copy link
Contributor

briskt commented Jan 24, 2020

I'm finding a need for an OR in a SELECT query. Alternatives presently include:

  1. performing two separate queries and merging the data together
  2. using raw SQL
  3. other?

Complications:

  1. interleaving sorted data becomes difficult to implement and comes at a performance penalty
  2. generating IN (?) arguments for raw SQL adds additional app code, effectively duplicating work already accomplished in the Pop library
  3. I haven't thought of other alternatives. Suggestions?

If I were to create an OrWhere method in the query builder, would this be of value? I'm not promising anything, as I haven't a clue what I'd be getting myself into. Just wanted to check ahead of time to see if it would be accepted.

@stanislas-m stanislas-m transferred this issue from gobuffalo/buffalo-pop Aug 10, 2020
@duckbrain
Copy link
Contributor

Having OR and AND adds the question of precedence. a AND b OR c can be interpreted (a AND b) OR c or a AND (b OR c).

I think the normal way of handling this is to have a more complex clause in your Where.

tx.Where("a_id = ? OR b_id = ?", idA, idB)

Where doesn't completely abstract the WHERE clause away from you, it handles it occurring multiple times if it does by ANDing them together.

Do you have a more specific example of what you want to OR together?

@sio4 sio4 added this to the Backlog milestone Sep 20, 2022
@sio4 sio4 added the f: sql about SQL support label Sep 24, 2022
@sio4
Copy link
Member

sio4 commented Sep 24, 2022

Could be considerable.

Related to #610 and some others including #777

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: sql about SQL support
Projects
None yet
Development

No branches or pull requests

3 participants