Re: [go-nuts] handling database.Query empty set

2020-09-13 Thread Andy Hall
I can assure you my query returns multiple rows which I why I then iterate around the result set and pass to conn.Write in a loop...I am aware of QueryRow and use it elsewhere...but agreed I should perhaps RTFM a bit more thanks !! On Sunday, September 13, 2020 at 10:49:57 AM UTC+1 mb0 wrote:

Re: [go-nuts] handling database.Query empty set

2020-09-13 Thread Martin Schnabel
sorry Andy, it seems i haven't read your example carefully enough. your question was what to do if the query returns multiple rows. i tried to explain that. however the query in your example looks like it will only ever return a single row, because you probably marked the username column in y

Re: [go-nuts] handling database.Query empty set

2020-09-13 Thread Andy Hall
thanks martin...it seems with no query handling the database Next func does not run anyway as the rows evaluate to false in the for loop... // tell other players in the room you have entered rows_users, err := database.Query("SELECT username FROM users WHERE room = ? AND username != ?", room, us

Re: [go-nuts] handling database.Query empty set

2020-09-12 Thread Martin Schnabel
hi Andy, when you take a look at the documentation of the Rows type returned by Query you will see a helpful example of its common use, appending the scanned results into a slice. my recommendation would be to follow this example and then check if the len(slice) == 0 to detect an empty set.