mirror of
https://github.com/groue/GRDB.swift
synced 2026-11-28 04:24:20 +00:00
One less known issue with associations :-)
This commit is contained in:
1 parent
df51d2887a
commit
45ff5f2fa1
1 file changed
-20
@@ -1442,26 +1442,6 @@ let request = Book
|
||||
|
||||
This code compiles, but you'll get a runtime fatal error "Not implemented: chaining a required association behind an optional association". Future versions of GRDB may allow such requests.
|
||||
|
||||
**You can't join two associations with the same [association key](#the-structure-of-a-joined-request) at the same level:**
|
||||
|
||||
```swift
|
||||
// NOT IMPLEMENTED
|
||||
let request = Book
|
||||
.including(required: Book.author) // key "author"
|
||||
.including(required: Book.author) // key "author"
|
||||
```
|
||||
|
||||
This code compiles, but you'll get a runtime fatal error "The association key `author` is ambiguous. Use the Association.forKey(_:) method is order to disambiguate.". Future versions of GRDB may allow such requests.
|
||||
|
||||
To join the same table twice, and make sure GRDB does not modify the fetched results in some future release, make sure no two associations have the same name on a given level:
|
||||
|
||||
```swift
|
||||
// OK
|
||||
let request = Book
|
||||
.including(required: Book.author.forKey("firstAuthor"))
|
||||
.including(required: Book.author.forKey("secondAuthor"))
|
||||
```
|
||||
|
||||
|
||||
## Future Directions
|
||||
|
||||
|
||||
Reference in new issue
Block a user