Skip to content
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

[11.x] Support named in-memory SQLite connections #53635

Open
wants to merge 2 commits into
base: 11.x
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions src/Illuminate/Database/Connectors/SQLiteConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,13 @@ public function connect(array $config)

// SQLite supports "in-memory" databases that only last as long as the owning
// connection does. These are useful for tests or for short lifetime store
// querying. In-memory databases may only have a single open connection.
if ($config['database'] === ':memory:') {
return $this->createConnection('sqlite::memory:', $config, $options);
// querying. In-memory databases may be anonymous (:memory:) or named.
if (
$config['database'] === ':memory:' ||
str_contains($config['database'], '?mode=memory') ||
str_contains($config['database'], '&mode=memory')
) {
return $this->createConnection('sqlite:'.$config['database'], $config, $options);
}

$path = realpath($config['database']);
Expand Down