Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot unmarshal array into Go value of type RequestError #3

Open
nathananderson98 opened this issue Sep 22, 2022 · 7 comments
Open

Comments

@nathananderson98
Copy link

nathananderson98 commented Sep 22, 2022

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!

@nathananderson98
Copy link
Author

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.

@nathananderson98
Copy link
Author

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]

@0x111
Copy link

0x111 commented Oct 22, 2022

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.

@danielchristianschroeter

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

@pgshow
Copy link

pgshow commented Apr 21, 2023

Me too, I encounter the same issue today.

@zach030
Copy link

zach030 commented May 11, 2023

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)

@delivey
Copy link

delivey commented Apr 10, 2024

go get github.com/nedpals/postgrest-go

Fixes it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants