supabase-community / godot-engine.supabase

A lightweight addon which integrates Supabase APIs for Godot Engine out of the box.
MIT License
159 stars 17 forks source link

calling .eq.update crashes it? i'm sorry, I don't really know if i did something wrong #41

Closed ghost closed 1 year ago

ghost commented 2 years ago

So my code is

    var query_task := Supabase.database.query(SupabaseQuery.new().from("creators").eq("id", "13").update({
        "data": {"key2": "value2"},
    }))

This should update it, right? Anyway, it crashes the game on the database_task _on_task_completed function. Apparently result_body is set to an array instead of a dictionary? I don't know how that's possible.

ghost commented 2 years ago

Also, I tried calling sign_in_anonymous() but i just got the error "invalid_request >> refresh token required"

fenix-hub commented 2 years ago

So my code is

  var query_task := Supabase.database.query(SupabaseQuery.new().from("creators").eq("id", "13").update({
      "data": {"key2": "value2"},
  }))

This should update it, right? Anyway, it crashes the game on the database_task _on_task_completed function. Apparently result_body is set to an array instead of a dictionary? I don't know how that's possible.

I can check that later, eventually the endpoint returns an Array if there are multiple rows updated instead of one. Maybe I'm mapping that wrongly

fenix-hub commented 2 years ago

Also, I tried calling sign_in_anonymous() but i just got the error "invalid_request >> refresh token required"

I think that anonymous login is not supported anymore, or "fixed" since it used the anonymous key but without identifying any user (which is not secure anyway). You can try this workaround https://github.com/supabase/gotrue/issues/68

ghost commented 2 years ago

okay, will do!

ghost commented 2 years ago

For the first issue, I didn't have permission to update the table since my policies were set incorrectly, so the returned array was empty. I have them set correctly now.

ghost commented 2 years ago

Now I can't upload images 😭 , the error is just empty

ghost commented 2 years ago

I am calling Supabase.storage.from("public").upload("thumbnails/test.png", "user://icon.png") and it doesn't work 😭

fenix-hub commented 2 years ago

@ShatReal the error could be empty because you didn't authenticate before uploading a file Make sure to have such flow

    var task:AuthTask= yield(Supabase.auth.sign_in(user_mail, user_pwd), "completed")
    var upload : StorageTask = yield(Supabase.storage.from("games").upload("icon.png", "res://icon.png"), "completed")

or use signals

fenix-hub commented 2 years ago

About the empty error: that's an issue coming from supabase backend, sadly :\ I'll reach out to Supabase devs to ask for a meaningful error