-
Notifications
You must be signed in to change notification settings - Fork 5
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Bug report
Describe the bug
Calling .insert(...).select().single() throws a runtime type error because the mock client returns a List instead of a single Map when a single row is expected.
Error
type 'List<dynamic>' is not a subtype of type 'Map<dynamic, dynamic>'
package:postgrest/src/postgrest_builder.dart 241:34 PostgrestBuilder._parseResponse
package:postgrest/src/postgrest_builder.dart 174:14 PostgrestBuilder._execute
To Reproduce
import 'package:test/test.dart';
import 'package:supabase/supabase.dart';
import 'package:mock_supabase_http_client/mock_supabase_http_client.dart';
void main() {
late SupabaseClient client;
late MockSupabaseHttpClient mockHttp;
setUp(() {
mockHttp = MockSupabaseHttpClient();
client = SupabaseClient('https://mock.supabase.co', 'anon', httpClient: mockHttp);
});
tearDown(() => mockHttp.reset());
test('insert + select().single() returns a Map', () async {
final row = {'id': 1, 'title': 'Test expense', 'amount': 1234};
final result = await client.from('expenses').insert(row).select().single();
expect(result, isA<Map<String, dynamic>>());
expect(result['id'], 1);
});
}
Expected behavior
When chaining .single() after .select(), the mock client should return a single object (Map<String, dynamic>) for a single-row insert, matching Supabase/PostgREST behavior, not a List.
Screenshots
N/A
System information
- OS: macOS (Apple Silicon)
- Version of mock_supabase_http_client: 0.0.3+2
- Browser (if applies): N/A
- Version of supabase-js: N/A
- Version of Node.js: N/A
Additional context
The failure happens only when .single() is used. Without .single(), the call returns a List and succeeds, but that doesn’t mimic PostgREST’s single-object response.
Roman-Dzerkal
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working