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

Refining Association Requests #422

Merged
merged 15 commits into from
Sep 30, 2018
Merged

Refining Association Requests #422

merged 15 commits into from
Sep 30, 2018

Conversation

groue
Copy link
Owner

@groue groue commented Sep 30, 2018

This pull request fixes a known issue with associations.

It is now possible to include or join an association several times in the definition of a single request:

// 1. Start from all books with their author...
var request = Book.including(required: Book.author)

// 2. Then filter on Spanish authors...
request = request.joining(required: Book.author.filter(Column("countryCode") == "ES"))

// 3. Then sort by author name and then book title.
let authorAlias = TableAlias()
request = request
    .joining(optional: Book.author.aliased(authorAlias))
    .order(authorAlias[Column("name")], Column("title"))

See the new "Refining Association Requests" chapter in AssociationBasics.md for more information and intended use cases.

@groue groue merged commit 366460b into development Sep 30, 2018
@groue groue deleted the feature/AssociationMerge branch September 30, 2018 14:39
@groue groue mentioned this pull request Oct 1, 2018
@groue groue added this to the GRDB 3.4.0 milestone Oct 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant