supabase / postgrest-dart

Dart client for PostgREST
https://supabase.com
MIT License
136 stars 38 forks source link

insert, update and delete return 301 when executed #15

Closed amitkhairnar44 closed 3 years ago

amitkhairnar44 commented 3 years ago

Bug report

Describe the bug

Some functions seem to return 301 status when executed. I have tried the select function and it's working properly but other don't work as intended. I'm able to fetch the data from the Postgrest DB but unable to update, insert or delete any row.

Code that I'm using

    var _client = PostgrestClient(postgRestEndpoint,
        schema: 'public', headers: {'apikey': apiKey});

    var response = await _client.from('Users').insert([
      {'name': 'Some User', 'email': 'someuser@example.com'}
    ]).execute();

Expected behaviour

A new row should be inserted in the Postgrest DB.

kiwicopple commented 3 years ago

Hey @amitkhairnar44 , you shouldn't need the execute(). https://supabase.io/docs/client/insert

If you remove it, hopefully that fixes the problem. I'll close this for now, but feel free to reopen if you are still experiencing difficulties

amitkhairnar44 commented 3 years ago

@kiwicopple But the README.md says to execute it.

I'll try it without 'execute()' and check.

phamhieu commented 3 years ago

I'm able to fetch the data from the Postgrest DB but unable to update, insert or delete any row.

Hi @amitkhairnar44, can you share the error message? you can get it with response.error.message. I tested on my end and i could be able to insert, update and delete.

I published a new version; only contains lint error fix so i don't think it's related. But you can give it a try.

you shouldn't need the execute()

@kiwicopple we need execute() to end the query chain like in python lib.

amitkhairnar44 commented 3 years ago

I'm able to fetch the data from the Postgrest DB but unable to update, insert or delete any row.

Hi @amitkhairnar44, can you share the error message? you can get it with response.error.message. I tested on my end and i could be able to insert, update and delete.

I published a new version; only contains lint error fix so i don't think it's related. But you can give it a try.

you shouldn't need the execute()

@kiwicopple we need execute() to end the query chain like in python lib.

@phamhieu Sure, I'll try and let you know.

amitkhairnar44 commented 3 years ago

@phamhieu It's returning response.error as null response.toJson() returns: {data: , status: 301, statusText: null, error: null}

amitkhairnar44 commented 3 years ago

Issue has been fixed 👍