-
Notifications
You must be signed in to change notification settings - Fork 34
Description
Bug report
Describe the bug
The Insert()
method in the Supabase Go library (postgrest-go
) consistently returns empty data ([]uint8 len: 0
) regardless of the returning
parameter, even when insertion is successful (count > 0). This prevents applications from accessing the inserted data directly from the Insert operation.
To Reproduce
Steps to reproduce the behavior, please provide code snippets or a repository:
- Create a Go project with the Supabase Go library
- Set up a database table (e.g., "incidents")
- Execute an Insert operation with a returning parameter
- Check the returned data and count values
- Observe that
count == 1
(successful insertion) butdata
is always empty
Code example:
package main
import (
"fmt"
"github.com/supabase-community/postgrest-go"
)
func main() {
client := postgrest.NewClient("your-supabase-url", "your-anon-key", nil)
incident := map[string]interface{}{
"complain_id": 1,
"status": "active",
}
data, count, err := client.
From("incidents").
Insert(incident, false, "id", "incident_id,status,location", "exact").
Execute()
if err != nil {
panic(err)
}
fmt.Printf("Count: %d\n", count) // Output: Count: 1
fmt.Printf("Data: %v\n", data) // Output: Data: [] (empty byte slice)
fmt.Printf("Data length: %d\n", len(data)) // Output: Data length: 0
}
Expected behavior
The data
should contain the inserted record(s) when specifying columns in the returning parameter. The method should return the actual inserted data as a byte slice that can be unmarshaled into the appropriate struct.
System information
- OS: macOS (darwin 24.6.0)
- Database: Supabase/PostgreSQL
- RLS: Disabled (confirmed not an RLS issue)
Additional context
Key findings:
- This is a fundamental library bug affecting ALL Insert operations
- The issue occurs regardless of the
returning
parameter (both"*"
and specific column names) - The insertion itself succeeds, only the data return is broken
- All existing code in production codebases work around this by ignoring the data return using
_
Impact:
This prevents applications from accessing the inserted data directly from the Insert operation, requiring additional queries to retrieve the inserted records, which impacts performance and adds complexity to applications.
Repository evidence:
The issue is reproducible across different tables and returning parameters. In our codebase, all Create*
functions work around this by ignoring the data return, indicating this is a known limitation.