Skip to content

Fetching rows from two different record types together. #671

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

Closed
alivepool opened this issue Dec 18, 2019 · 2 comments
Closed

Fetching rows from two different record types together. #671

alivepool opened this issue Dec 18, 2019 · 2 comments
Labels

Comments

@alivepool
Copy link

What did you do?

I have two records r1, r2 who have an association to another record/s through mapping records.
I am trying to fetch these two different types of Records together.
I am not able to frame query interface for this case. I am expecting something similar to 'UNION ALL'.

What did you expect to happen?

I am expecting to get values from these two records together along with their respective associations.

What happened instead?

I am not able to frame the query. How to achieve this in GRDB, I am not able to wrap my head around that.

Environment

GRDB flavor(s): GRDB
GRDB version: 4.6.2
Installation method: Swift Package Manager
Xcode version: 11.3
Swift version: 5.1.3
Platform(s) running GRDB: iOS
macOS version running Xcode: 10.14.6

Demo Project

@groue
Copy link
Owner

groue commented Dec 18, 2019

Hello @alivepool,

Since it looks like you want to use UNION ALL, don't spend time looking for a solution in the query interface or associations. There is no UNION ALL there. GRDB does not, currently, generate this SQL operator.

Instead, I suggest you solve your issue directly at the SQL level. Design your SQL query with the usual care, design a record type that can decode its results, and you'll be good to go.

@groue groue added the support label Dec 18, 2019
@alivepool
Copy link
Author

Will do it with SQL then.

Thanks @groue !!

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

No branches or pull requests

2 participants