Skip to content

FatalError when fetching associated records using dedicated record type #1274

Answered by groue
juliensagot asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @juliensagot,

I don't know if this is a GRDB bug, or if your program behaves as expected - to answer this I'll have to think a little more 😅

The cause of the issue is there:

struct Exercise: Codable, Identifiable, TableRecord, FetchableRecord, MutablePersistableRecord {
    var id: String
  
    // Primary Muscle Groups
    static let primaryMuscleGroups = hasMany(
        MuscleGroup.self,
        through: Exercise.hasMany(PrimaryMuscleGroup.self), // <- 1
        using: PrimaryMuscleGroup.muscleGroup
    )
    .forKey("primaryMuscleGroups")                          // <- 2
}
  1. Exercise.hasMany(PrimaryMuscleGroup.self) defines an association with key "primaryMuscleGroups" (the defau…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by juliensagot
Comment options

You must be logged in to vote
2 replies
@groue
Comment options

groue Sep 5, 2022
Maintainer

@juliensagot
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants