Closed marcustut closed 3 years ago
Looking further into the URL issue, it seems that because local postgrest would run on an url like http://localhost:3000
and therefore the path to a table would be http://localhost:3000/<table_name>
but since supabase has its postgrest server at https://<supabase_url>/rest/v1
so the path to a table would be https://<supabase_url>/rest/v1/<table_name>
.
But if I directly pass https://<supabase_url>/rest/v1
to the NewClient func, it wouldn't work as well due to how url parsing is implemented, it will result in the following baseURL
// So doing the following would result in a correct path
client.From("/rest/v1/products")
// instead of
client.From("products")
probably we should set a func param while creating the client to specify the nested path?
No we must be able to give url like first example. I will look at this issue.
Can you try adding https://
in your url?
Can you try adding
https://
in your url?
It's already added, this is how I specify it
You must define like this. This is just a postgrest library and you must specify postgrest path. Supabase's postgrest runs in rest/v1/
. That's cause of your problem 😆
You must define like this. This is just a postgrest library and you must specify postgrest path. Supabase's postgrest runs in
rest/v1/
. That's cause of your problem 😆
Ah.. yea tested it just now, my bad. turns out you need to set https://<supabase_url>/rest/v1/
for it to work instead of https://<supabase_url>/rest/v1
However, I still can't get Insert()
to work, still trying to debug it, however Select()
works flawlessly.
I got insert()
to work, the problem is with me again 😅 I was passing map[string]interface{}
as value
which json.Marshal
doesn't know how to marshal it into a correct json object.
So I wrote a struct with proper json struct tags that correspond to the table's field name then it worked.
Anyways, I found that the examples is quite lacking, shall I write few more examples under the test/
folder?
We will add more examples and you're welcome to contribute 😉
Bug report
Describe the bug
So when I try to insert data with the following code snippet, I expect it to send a request to
https://<supabase_url>/rest/v1/products
but it seems like theExecute()
function is not sending the request to the correct URL.The result of trying to run this is that I get the response as below, after a google search it seems like this is what Kong would respond if it can't find a route
So I try to directly change the
client.clientTransport.baseURL.Path
tohttps://<supabase_url>/rest/v1/products
, the request is sent to the correct place where I can see a postgrest response but the query is still not successfully created yet. I'm suspecting is that the way the querybuilder marshal json is making some errors here.To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
Expected behavior
The request should be sent to the correct url and querybuilder should properly marshal
value
into jsonScreenshots
Shown above
System information
Additional context
I will try fixing it and if I do, I will create a PR.