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

Move eager loading of hasMany associations to FetchRequest #542

Merged
merged 5 commits into from
Jun 4, 2019

Conversation

groue
Copy link
Owner

@groue groue commented Jun 1, 2019

This PR fixes two things:

  • Eager loading of hasMany associations (Eager Loading of HasMany associations #525) was defined on QueryInterfaceRequest, not on the FetchRequest protocol. This had GRDB 4.0 define many overloads, for requests of rows or records, just to activate this feature. Such overloads were necessary in RxGRDB as well.
  • The result of the fundamental FetchRequest.prepare method was a tuple, and impossible to extend.

Now FetchRequest is able of eager loading, even if this isn't visible on the public API (one can't add eager loading to custom FetchRequest):

+struct PreparedRequest {
+    var statement: SelectStatement
+    var adapter: RowAdapter?
+    init(statement: SelectStatement, adapter: RowAdapter? = nil)
+}
 
 protocol FetchRequest {
+    // deprecated
     func prepare(_ db: Database, forSingleResult singleResult: Bool) throws -> (SelectStatement, RowAdapter?)
+    func preparedRequest(_ db: Database, forSingleResult singleResult: Bool) throws -> PreparedRequest
 }

@groue groue added this to the GRDB 4.1.0 milestone Jun 1, 2019
@groue groue merged commit c1cbe51 into development Jun 4, 2019
@groue groue deleted the dev/FetchRequest-cleanup branch June 4, 2019 16:41
@groue groue mentioned this pull request Jun 14, 2019
10 tasks
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