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

union doesn't work for union of fields #23

Open
Ana06 opened this issue Apr 16, 2019 · 0 comments
Open

union doesn't work for union of fields #23

Ana06 opened this issue Apr 16, 2019 · 0 comments

Comments

@Ana06
Copy link

Ana06 commented Apr 16, 2019

I had expected that the following code:

BsRequest.where(id: BsRequestAction.where(id: [1,2]).select(:bs_request_id).union(Review.where(id: [1,2,3]).select(:bs_request_id)))

to produce the following query:

SELECT  `bs_requests`.* FROM `bs_requests` WHERE `bs_requests`.`id` IN ((SELECT `bs_request_actions`.`bs_request_id` FROM `bs_request_actions` WHERE `bs_request_actions`.`id` IN (1, 2)) UNION (SELECT `reviews`.`bs_request_id` FROM `reviews` WHERE `reviews`.`id` IN (1, 2, 3)))

Instead, it produces:

SELECT  `bs_requests`.* FROM `bs_requests` WHERE `bs_requests`.`id` IN (SELECT `bs_request_actions`.`id` FROM ( (SELECT `bs_request_actions`.`bs_request_id` FROM `bs_request_actions` WHERE `bs_request_actions`.`id` IN (1, 2)) UNION (SELECT `reviews`.`bs_request_id` FROM `reviews` WHERE `reviews`.`id` IN (1, 2, 3)) ) `bs_request_actions`)
@Ana06 Ana06 changed the title union doesn't work for ùnion of fields union doesn't work for union of fields Apr 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant