Hi, I was starting with the supabase storage and I...
# sql
c
Hi, I was starting with the supabase storage and I think there is some bug in the dashboard's SQL editor or I don't know what it is 😅 I ran this command in the SQL editor
Copy code
sql
select storage.foldername('invoices/Test-Patient/2322_22-05-2021.pdf') from storage.objects;
I expect one result with folders as
["invoices", "Test-Patient"]
but I am getting two duplicate entries. I only have one file in the whole bucket and when I added one more I got three duplicate entries.
This also happens with other helper functions like filename, foldername, and extension
g
If you are passing a string to that function then just do select storage.foldername(string) With no from table. If you are trying to process files in your storage table then use column name in the function with the from like you have.
c
@garyaustin that worked but could you please also explain to me why that happened?
g
With from you are asking for all rows in the table, but instead of * or a column list you are telling Postgres to return that function for each row.
c
I copied the command from the docs so just thought something went wrong.
Should I make a PR to update docs 🤨
g
The docs are fine. They are showing an example of using the function on the results of a table select. “name” is the column name in the object table. You were passing in a string directly to the function so would only use the function itself and not the rest doing a table lookup. Of course if unclear you could suggest an improvement.
c
Thanks for you response 🥰
n
Thread was archived by @celeronCoder. Anyone can send a message to unarchive it.