Trouble with QRM while joining the same tables multiple times using aliases #529
olivierstamand
started this conversation in
General
Replies: 1 comment
-
|
For self join you need to specify an alias tag: type WorkoutDetails struct {
model.Workouts
WorkoutMedia model.Media `alias:"workout_media.*"`
WorkoutBlocks []struct {
model.WorkoutBlocks
WorkoutExercises []struct {
Exercise model.Exercises
ExerciseMedia model.Media `alias:"exerciseMedia.*"`
Muscles []struct {
model.Muscles
MuscleMedia model.Media `alias:"muscleMedia.*"`
}
model.WorkoutExercises
Sets []struct {
model.Sets
}
}
}
}Also you have a lot of joins here, in case of performance issue consider SELECT_JSON instead(for whole or part of the query). |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, i'm doing a query where i need to join multiples times the same tables. I'm using aliases to differentiate them, but when mapping to my struct, it's not working. Here is my query .
`
workoutMedia := Media.AS("workout_media")
exerciseMedia := Media.AS("exercise_media")
muscleMedia := Media.AS("muscle_media")
And here is my struct being mapped to
Everything maps correctly, except Medias.
Beta Was this translation helpful? Give feedback.
All reactions