supabase / postgrest-dart

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

Headers["Accept"] is leaking. #63

Closed DanMossa closed 2 years ago

DanMossa commented 2 years ago

If I have

final Supabase _supabase = Supabase.instance;

 static final _users = _supabase.client.from('users');

  static Future<UserModel?> getUser(String userId, [String columns = '*']) async {
    final PostgrestResponse res = await _users.select(columns)
        .eq('user_id', userId)
        .maybeSingle()
        .execute();
  }

  static Future<List<UserModel>> getMatchingUsers(UserModel callingUser,
      [String columns = "*"]) async {
    final PostgrestResponse res = await _users.select(columns)
        .execute();
}

And I first call getUser, then this line is hit

    headers['Accept'] = 'application/vnd.pgrst.object+json';

If I then call anything else, such as getMatchingUsers, an error occurs because more than 1 row is returned.

DanMossa commented 2 years ago

I'm dumb and I shouldn't have reused static final _users = _supabase.client.from('users');