Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/src/mock_supabase_http_client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,9 @@ class MockSupabaseHttpClient extends BaseClient {

// Handle basic filtering
queryParams.forEach((key, value) {
if (returningRows.isEmpty) {
return;
}
if (key != 'select' &&
key != 'order' &&
key != 'limit' &&
Expand Down
38 changes: 38 additions & 0 deletions test/mock_supabase_http_client_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,44 @@ void main() {
expect(posts.length, 0);
});

test('Select after deleting all items', () async {
// Insert an item
await mockSupabase
.from('posts')
.insert({'id': 1, 'title': 'To be deleted'});
await mockSupabase.from('posts').delete().eq('id', 1);
final posts = await mockSupabase.from('posts').select().eq('id', 1);
expect(posts.length, 0);
});

test('Select with a referenced table filter after deleting all items',
() async {
// Insert an item
await mockSupabase.from('posts').insert({
'id': 1,
'title': 'To be deleted',
'authors': {'id': 1, 'name': 'Author One'}
});
await mockSupabase.from('posts').delete().eq('id', 1);
final posts = await mockSupabase
.from('posts')
.select('*, authors(*)')
.eq('authors.name', 'Author One');
expect(posts.length, 0);
});

test('Select with chained filters where the first returns no rows',
() async {
// Insert an item
await mockSupabase.from('posts').insert({'id': 1, 'title': 'First post'});
final posts = await mockSupabase
.from('posts')
.select()
.eq('id', 2)
.eq('title', 'First post');
expect(posts.length, 0);
});

test('Select all columns', () async {
// Test selecting all records
await mockSupabase.from('posts').insert([
Expand Down
Loading