From e792dfe5b31a2ee8467be5b88ce04dc21d92ba3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 22 Nov 2024 22:07:30 +0100 Subject: [PATCH 1/2] [11.x] Support named in-memory SQLite connections --- src/Illuminate/Database/Connectors/SQLiteConnector.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Database/Connectors/SQLiteConnector.php b/src/Illuminate/Database/Connectors/SQLiteConnector.php index ddedfbf99e9e..160d82eec59f 100755 --- a/src/Illuminate/Database/Connectors/SQLiteConnector.php +++ b/src/Illuminate/Database/Connectors/SQLiteConnector.php @@ -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']); From 33a6a40019676ead39472c9d4f5018e797761657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20=C5=A0tancl?= Date: Fri, 22 Nov 2024 22:37:45 +0100 Subject: [PATCH 2/2] code style --- src/Illuminate/Database/Connectors/SQLiteConnector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Illuminate/Database/Connectors/SQLiteConnector.php b/src/Illuminate/Database/Connectors/SQLiteConnector.php index 160d82eec59f..0576a77508ae 100755 --- a/src/Illuminate/Database/Connectors/SQLiteConnector.php +++ b/src/Illuminate/Database/Connectors/SQLiteConnector.php @@ -26,7 +26,7 @@ public function connect(array $config) str_contains($config['database'], '?mode=memory') || str_contains($config['database'], '&mode=memory') ) { - return $this->createConnection('sqlite:' . $config['database'], $config, $options); + return $this->createConnection('sqlite:'.$config['database'], $config, $options); } $path = realpath($config['database']);