supabase-go
supabase-go copied to clipboard
cannot unmarshal array into Go value of type RequestError
Based on the sparse readme examples, I've got an insert query that looks like
var results map[string]interface{} // I also tried the type RequestError, no luck
err := supaClient.DB.From("table").Insert(user).Execute(results)
All other operations I've tried yield similar results. Any ideas on how to avoid this error being returned? The operations seem to be working in Supabase (rows are inserted), but the err
object is always this message.
Also, I have no idea how to go about building queries with this wrapper, are there any resources to point to? I'm glad to write up some docs for this wrapper if I can get some guidance.
Thanks for the work of putting this together!
Digging into the code with a debugger, I realized that the response from the server I was getting was 201, and the check in request_builder.go
was only looking for 200, so it marked my successful update as an error. Then I realized that your postgrest_go
package has that fix, so this one must just not be up to date with that package. I'm fairly new to go, so I'm not sure how that is done, but until a fix is made, I will probably just copy-paste in that fixed file.
Alright, this is a bit of a blocker, so I'm still trying to fix it...
Running go get github.com/nedpals/postgrest@latest
doesn't find the repo, which I'm assuming is because its not published as a standalone go package..?
Running go list -m -u all
shows that my version of postgrest-go
is behind one version
github.com/nedpals/postgrest-go v0.1.2 [v0.1.3]
Try to run go get github.com/nedpals/postgrest-go
you are missing the -go
part from your go get command. The releases are tagged, latest tag being the one you list also.
I just started with a simple insert example today and I had the same issue. "go get github.com/nedpals/postgrest-go" resolved it:
go get github.com/nedpals/postgrest-go
go: downloading github.com/nedpals/postgrest-go v0.1.3
go: upgraded github.com/nedpals/postgrest-go v0.1.2 => v0.1.3
Me too, I encounter the same issue today.
The response is array of inserted rows, you need to define the result with array.
var results []Row
err := supaClient.DB.From("table").Insert(user).Execute(&results)
go get github.com/nedpals/postgrest-go
Fixes it for me