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

Insert and Upsert do not work #51

Open
princefishthrower opened this issue Jun 14, 2024 · 3 comments
Open

Insert and Upsert do not work #51

princefishthrower opened this issue Jun 14, 2024 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@princefishthrower
Copy link

Bug report

Describe the bug

As the title states, Insert and Upsert do not work - they fail to create and/or update records respectively.

To Reproduce

Try to call Insert or Upsert on any postgres table using supabase-go. I've tried the following combinations:

s.Client.From("my_table").Insert(bytes, true, "", "minimal", "exact").Execute()
s.Client.From("my_table").Insert(bytes, false, "", "minimal", "exact").Execute()
s.Client.From("my_table").Insert(bytes, true, "", "representation", "exact").Execute()
s.Client.From("my_table").Insert(bytes, false, "", "representation", "exact").Execute()
s.Client.From("my_table").Upsert(bytes, "", "representation", "exact").Execute()
s.Client.From("my_table").Upsert(bytes, "", "minimal", "exact").Execute()
s.Client.From("my_table").Upsert(bytes, "my_primary_key_column", "representation", "exact").Execute()
s.Client.From("my_table").Upsert(bytes, "my_primary_key_column", "minimal", "exact").Execute()

I've tried for when the row exists and when it does not; Upsert and Insert fail to update or create the record respectively. The strangest thing is that no error is reported, and with "representation", I always get an empty array.

Expected behavior

The desired row should be inserted. In the case of already existing by primary key, upserted.

Screenshots

N/A

System information

  • OS: macOS
  • Go version 1.21.11

Additional context

I do notice there are no tests including Insert or Upsert, perhaps adding those would help be a cross check against this bug into the future.

@princefishthrower princefishthrower added the bug Something isn't working label Jun 14, 2024
@muratmirgun
Copy link
Member

Thanks for the issue first of all!
I will check and send the result here asap!

@muratmirgun
Copy link
Member

Which postgrest-go version did you use?

@muratmirgun muratmirgun self-assigned this Jun 21, 2024
@dmedora
Copy link

dmedora commented Jul 6, 2024

Just noting that Insert works for me, like so:

rowJSON := map[string]string{"column1":"val1", "column2":"val2"}
client.From(mytable).Insert(rowJSON, false, "", "representation", "").Execute()

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

3 participants