File tree Expand file tree Collapse file tree 4 files changed +24
-12
lines changed Expand file tree Collapse file tree 4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change 44
55use Illuminate \Database \Connection as BaseConnection ;
66use Illuminate \Support \Arr ;
7- use Illuminate \Support \Str ;
87use MongoDB \Client ;
98
109class Connection extends BaseConnection
@@ -151,7 +150,7 @@ public function disconnect()
151150 }
152151
153152 /**
154- * Determine if the given configuration array has a UNIX socket value .
153+ * Determine if the given configuration array has a dsn string .
155154 *
156155 * @param array $config
157156 * @return bool
@@ -162,22 +161,14 @@ protected function hasDsnString(array $config)
162161 }
163162
164163 /**
165- * Get the DSN string for a socket configuration.
164+ * Get the DSN string form configuration.
166165 *
167166 * @param array $config
168167 * @return string
169168 */
170169 protected function getDsnString (array $ config )
171170 {
172- $ dsn_string = $ config ['dsn ' ];
173-
174- if (Str::contains ($ dsn_string , 'mongodb:// ' )) {
175- $ dsn_string = Str::replaceFirst ('mongodb:// ' , '' , $ dsn_string );
176- }
177-
178- $ dsn_string = rawurlencode ($ dsn_string );
179-
180- return "mongodb:// {$ dsn_string }" ;
171+ return $ config ['dsn ' ];
181172 }
182173
183174 /**
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ class DsnTest extends TestCase
4+ {
5+ public function test_dsn_works ()
6+ {
7+ $ this ->assertInstanceOf (\Illuminate \Database \Eloquent \Collection::class, DsnAddress::all ());
8+ }
9+ }
10+
11+ class DsnAddress extends Address
12+ {
13+ protected $ connection = 'dsn_mongodb ' ;
14+ }
Original file line number Diff line number Diff line change @@ -51,6 +51,7 @@ protected function getEnvironmentSetUp($app)
5151 $ app ['config ' ]->set ('database.default ' , 'mongodb ' );
5252 $ app ['config ' ]->set ('database.connections.mysql ' , $ config ['connections ' ]['mysql ' ]);
5353 $ app ['config ' ]->set ('database.connections.mongodb ' , $ config ['connections ' ]['mongodb ' ]);
54+ $ app ['config ' ]->set ('database.connections.dsn_mongodb ' , $ config ['connections ' ]['dsn_mongodb ' ]);
5455
5556 $ app ['config ' ]->set ('auth.model ' , 'User ' );
5657 $ app ['config ' ]->set ('auth.providers.users.model ' , 'User ' );
Original file line number Diff line number Diff line change 1111 'database ' => 'unittest ' ,
1212 ],
1313
14+ 'dsn_mongodb ' => [
15+ 'driver ' => 'mongodb ' ,
16+ 'dsn ' => 'mongodb://mongodb:27017 ' ,
17+ 'database ' => 'unittest ' ,
18+ ],
19+
1420 'mysql ' => [
1521 'driver ' => 'mysql ' ,
1622 'host ' => 'mysql ' ,
You can’t perform that action at this time.
0 commit comments