kevinl (37) [Avatar] Offline
#1
The following section of the code example seems to be incorrect regarding populating the `Comments` field of a Post struct
rows, err := Db.Query("SELECT id, content, author FROM comments")


It seems it should be
rows, err := Db.Query("SELECT id, content, author FROM comments WHERE post_id = $1", id)


The existing code seems to overall mistakenly have a query that'll return all comments instead of only the ones associated with the id of a specific post passed in the function.
Sau Sheong (20) [Avatar] Offline
#2
Thanks for your comments, may I know which listing this is please?
kevinl (37) [Avatar] Offline
#3
Sau Sheong wrote:Thanks for your comments, may I know which listing this is please?


Hi, sorry for being so late to reply: Page 143 inside the GetPost field.