supabase / supabase-js

An isomorphic Javascript client for Supabase. Query your Supabase database, subscribe to realtime events, upload and download files, browse typescript examples, invoke postgres functions via rpc, invoke supabase edge functions, query pgvector.
https://supabase.com
MIT License
3.29k stars 272 forks source link

SupabaseClient returned when `.select()` is not included on query #27

Closed zlwaterfield closed 4 years ago

zlwaterfield commented 4 years ago

Bug report

Describe the bug

When I do not include .select('*') on the query the SupabaseClient is returned and the request is not made. The documentation says: "If not used, all columns in the table will be returned." so both should work based on that wording.

With select

  async getAll() {
    const res = await SupabaseService
      .from<InvitationQuestion>('invitation_question')
      .select('*')
      .eq('wedding_id', this.weddingId)
    return res.body;
  }

res result: Screen Shot 2020-08-31 at 11 06 19 AM

Without select

  async getAll() {
    const res = await SupabaseService
      .from<InvitationQuestion>('invitation_question')
      .eq('wedding_id', this.weddingId)
    return res.body;
  }

res result: Screen Shot 2020-08-31 at 11 07 19 AM

kiwicopple commented 4 years ago

I think this one should be a docs edit.

We don't won't "execute" the command until we know whether the users is selecting, updateing, deleteing etc

I'm guessing the "If not used, all columns in the table will be returned" is referring to not using the columns param. i.e.

await SupabaseService
      .from<InvitationQuestion>('invitation_question')
      .select('*')
      .eq('wedding_id', this.weddingId)
      .select()

The empty .select() should return all columns

zlwaterfield commented 4 years ago

Ah ok thanks, ya it might just be a document change needed. I can make a PR for that.

zlwaterfield commented 4 years ago

PR: https://github.com/supabase/supabase/pull/174

zlwaterfield commented 4 years ago

PR was merge.

kiwicopple commented 4 years ago

Thanks for the PR @zlwaterfield !