supabase / postgrest-py

PostgREST client for Python. This library provides an ORM interface to PostgREST
https://postgrest-py.readthedocs.io
MIT License
236 stars 52 forks source link

select() does not select all columns by default #507

Closed 9t8 closed 1 month ago

9t8 commented 2 months ago

Bug report

Describe the bug

The docs say the columns parameter of select() "defaults to *." It does not.

To Reproduce

  1. Run supabase.table("t").select("*"), and get everything in t.
  2. Run supabase.table("t").select(""), and get everything in t.
  3. Run supabase.table("t").select(), and get no data.

Expected behavior

supabase.table("t").select() should get everything in t. I understand "defaults to *" to mean * is the default argument.

chrisLucchini commented 2 months ago

Hello,

As you've correctly pointed out, there is a discrepancy between the documentation and the actual behavior of the select() method. The documentation states that if no columns are provided, the select() function "defaults to *", which implies that all columns should be selected. However, in the current implementation, if no arguments are passed to select(), it results in a HEAD request, which doesn't return any data.

I think HEAD request can be useful for users that only check if table exist or not without fetching any data which can slow down the request. So perhaps an update for documentation is preferable in this case

grdsdev commented 2 months ago

Hi, thanks for reporting this.

Behavior should be aligned between client libs, select() without arguments should default to * all columns.

If you need to use HEAD method, you can specify head=True when calling the select method (just like JS), at least this should be the behavior in Python too.

From what I see, this isn't supported as expected.


This fix would be a breaking change, tho currently it has the wrong behavior, @silentworks what do you think about this?

silentworks commented 1 month ago

I think we should apply the breaking change since this is a bug fix, the current behavior is a bug. We should probably do a minor release and not a patch release for this though.

grdsdev commented 1 month ago

Agreed, I'll push a PR with the fix.