Skip to content

Commit 19f1cdd

Browse files
committed
fix: follow suggestions
1 parent 825a4fe commit 19f1cdd

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

src/Schema/Builder.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ public function getTables($schema = null)
158158
}
159159

160160
// Skip views it doesnt suport aggregate
161-
$isView = ($collectionInfo['type'] ?? '') === 'view';
161+
$isView = $collectionInfo->getType() === 'view';
162162
$stats = null;
163163

164164
if ($isView) {
@@ -201,10 +201,10 @@ public function getViews($schema = null)
201201
}
202202

203203
// Skip views it doesnt suport aggregate
204-
$isView = ($collectionInfo['type'] ?? '') === 'view';
204+
$isNotView = $collectionInfo->getType() !== 'view';
205205
$stats = null;
206206

207-
if (! $isView) {
207+
if ($isNotView) {
208208
continue;
209209
}
210210

tests/SchemaTest.php

+4-20
Original file line numberDiff line numberDiff line change
@@ -400,11 +400,7 @@ public function testGetTables()
400400
$dbName = DB::connection('mongodb')->getDatabaseName();
401401

402402
// Create a view (this creates system.views)
403-
DB::connection('mongodb')->getDatabase()->command([
404-
'create' => 'test_view',
405-
'viewOn' => 'newcollection',
406-
'pipeline' => [],
407-
]);
403+
DB::connection('mongodb')->getDatabase()->createCollection('test_view', ['viewOn' => 'newcollection']);
408404

409405
$tables = Schema::getTables();
410406
$this->assertIsArray($tables);
@@ -438,11 +434,7 @@ public function testGetViews()
438434
DB::connection('mongodb')->table('newcollection_two')->insert(['test' => 'value']);
439435
$dbName = DB::connection('mongodb')->getDatabaseName();
440436

441-
DB::connection('mongodb')->getDatabase()->command([
442-
'create' => 'test_view',
443-
'viewOn' => 'newcollection',
444-
'pipeline' => [],
445-
]);
437+
DB::connection('mongodb')->getDatabase()->createCollection('test_view', ['viewOn' => 'newcollection']);
446438

447439
$tables = Schema::getViews();
448440

@@ -476,11 +468,7 @@ public function testGetTableListing()
476468
DB::connection('mongodb')->table('newcollection_two')->insert(['test' => 'value']);
477469

478470
// Create a view (this creates system.views)
479-
DB::connection('mongodb')->getDatabase()->command([
480-
'create' => 'test_view',
481-
'viewOn' => 'newcollection',
482-
'pipeline' => [],
483-
]);
471+
DB::connection('mongodb')->getDatabase()->createCollection('test_view', ['viewOn' => 'newcollection']);
484472

485473
$tables = Schema::getTableListing();
486474

@@ -517,11 +505,7 @@ public function testGetTableListingBySchema()
517505
public function testSystemCollectionsArePresentButFiltered()
518506
{
519507
// Create a view to trigger system.views collection
520-
DB::connection('mongodb')->getDatabase()->command([
521-
'create' => 'test_view',
522-
'viewOn' => 'newcollection',
523-
'pipeline' => [],
524-
]);
508+
DB::connection('mongodb')->getDatabase()->createCollection('test_view', ['viewOn' => 'newcollection']);
525509

526510
// Get all collections directly from MongoDB
527511
$allCollections = DB::connection('mongodb')->getDatabase()->listCollectionNames();

0 commit comments

Comments
 (0)