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

Storage schema always returning empty? #197

Closed
samuelOsborne opened this issue Dec 16, 2023 · 3 comments
Closed

Storage schema always returning empty? #197

samuelOsborne opened this issue Dec 16, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@samuelOsborne
Copy link

Bug report

Describe the bug

When using the Storage schema and accessing the objects table (I just need the name), it always returns an empty array.

To Reproduce

Create a client with the 'storage' schema set :

        let storageClient = SupabaseClient(supabaseURL: URL(string: "...")!, supabaseKey: "...", options: SupabaseClientOptions(db: SupabaseClientOptions.DatabaseOptions(schema: "storage")))

Try and query some data:

struct Storage: Encodable, Decodable {
//    var id: UUID?
//    var bucketID: String?
    var name: String?
//    var owner: UUID?
//    var createdAt: Date?
//    var updatedAt: Date?
//    var lastAccessedAt: Date?
//    var metadata: [String: String]? // Assuming a dictionary to represent JSONB data
//    var pathTokens: [String]? // Assuming an array of strings for path tokens
//    var version: String?
//    var ownerID: String?
}

let storageFile: [Storage] = try await storageClient.database
    .from("objects")
    .execute().value

print(storageFile)

Expected behavior

Should return the whole objects table.

Additional context

Personally just need the "name" column data. I think using the objects table is better than saving the path to files inside supabase storage myself (duplicate data)?

@samuelOsborne samuelOsborne added the bug Something isn't working label Dec 16, 2023
@grdsdev
Copy link
Collaborator

grdsdev commented Dec 17, 2023

Hi @samuelOsborne

I made a few tests and it worked as expected, and I could query the storage schema.

Make sure the storage.objects table has RLS correctly defined allowing access, if that still doesn't work for you, let me know.

@grdsdev
Copy link
Collaborator

grdsdev commented Dec 17, 2023

Added a PR for allowing to switch schema and improving this a bit, #199

@samuelOsborne
Copy link
Author

Thanks @grdsdev still trying to get my head around policies but its working. That PR looks great, cheers!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants