-
Notifications
You must be signed in to change notification settings - Fork 1.4k
PHPORM-289 Support Laravel 12 #3283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
4068303
0cbc826
6381b8e
a8c8a54
18cae95
d650305
96b24cb
87d89e3
00ffc94
f5a5468
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,7 @@ | |
| use Closure; | ||
| use MongoDB\Collection; | ||
| use MongoDB\Driver\Exception\ServerException; | ||
| use MongoDB\Laravel\Connection; | ||
| use MongoDB\Model\CollectionInfo; | ||
| use MongoDB\Model\IndexInfo; | ||
|
|
||
|
|
@@ -16,18 +17,22 @@ | |
| use function array_keys; | ||
| use function array_map; | ||
| use function array_merge; | ||
| use function array_values; | ||
| use function assert; | ||
| use function count; | ||
| use function current; | ||
| use function implode; | ||
| use function in_array; | ||
| use function is_array; | ||
| use function is_string; | ||
| use function iterator_to_array; | ||
| use function sort; | ||
| use function sprintf; | ||
| use function str_ends_with; | ||
| use function substr; | ||
| use function usort; | ||
|
|
||
| /** @property Connection $connection */ | ||
| class Builder extends \Illuminate\Database\Schema\Builder | ||
| { | ||
| /** | ||
|
|
@@ -137,9 +142,10 @@ public function dropAllTables() | |
| } | ||
| } | ||
|
|
||
| public function getTables() | ||
| /** @param string|null $schema Database name */ | ||
| public function getTables($schema = null) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are the signature changes here also a potential BC break for Laravel 11 users, or would you not expect anyone to extend this class?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is a breaking change if someone extends our class... I hope nobody does. We should make more classes final. |
||
| { | ||
| $db = $this->connection->getDatabase(); | ||
| $db = $this->connection->getDatabase($schema); | ||
| $collections = []; | ||
|
|
||
| foreach ($db->listCollectionNames() as $collectionName) { | ||
|
|
@@ -165,9 +171,23 @@ public function getTables() | |
| return $collections; | ||
| } | ||
|
|
||
| public function getTableListing() | ||
| public function getTableListing($schema = null, $schemaQualified = true) | ||
jmikola marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| $collections = iterator_to_array($this->connection->getDatabase()->listCollectionNames()); | ||
| $collections = []; | ||
|
|
||
| if ($schema === null || is_string($schema)) { | ||
| $collections[$schema ?? ''] = iterator_to_array($this->connection->getDatabase($schema)->listCollectionNames()); | ||
| } elseif (is_array($schema)) { | ||
| foreach ($schema as $db) { | ||
| $collections[$db] = iterator_to_array($this->connection->getDatabase($db)->listCollectionNames()); | ||
| } | ||
| } | ||
|
|
||
| if ($schema && $schemaQualified) { | ||
| $collections = array_map(fn ($db, $collections) => array_map(static fn ($collection) => $db . '.' . $collection, $collections), array_keys($collections), $collections); | ||
| } | ||
|
|
||
| $collections = array_merge(...array_values($collections)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but that's how the feature is designed. |
||
|
|
||
| sort($collections); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.