fix dsn so that sqlite:///full/unix/path/test.db and sqlite://c:/full/windows/path/test.db works
This commit is contained in:
parent
1945b0d7a1
commit
ea803566b6
@ -350,6 +350,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
|
||||
*/
|
||||
public function parseDsn($dsn)
|
||||
{
|
||||
|
||||
|
||||
//fix linux sqlite dsn so that it will parse correctly
|
||||
$dsn = str_replace("///", "/", $dsn);
|
||||
|
||||
// silence any warnings
|
||||
$parts = @parse_url($dsn);
|
||||
|
||||
@ -373,6 +378,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
|
||||
$parts['database'] = ':memory:';
|
||||
$parts['dsn'] = 'sqlite::memory:';
|
||||
} else {
|
||||
//fix windows dsn we have to add host: to path and set host to null
|
||||
if (isset($parts['host'])) {
|
||||
$parts['path'] = $parts['host'] . ":" . $parts["path"];
|
||||
$parts["host"] = null;
|
||||
}
|
||||
$parts['database'] = $parts['path'];
|
||||
$parts['dsn'] = $parts['scheme'] . ':' . $parts['path'];
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase {
|
||||
// sqlite://full/unix/path/to/file.db
|
||||
// It expects only // since it thinks it is parsing a url
|
||||
// The problem after that is that the dns is not valid when being passed to PDO
|
||||
$sqlite = 'sqlite:/full/unix/path/to/file.db';
|
||||
$sqlitewin = 'sqlite:c:/full/windows/path/to/file.db';
|
||||
$sqlite = 'sqlite:///full/unix/path/to/file.db';
|
||||
$sqlitewin = 'sqlite://c:/full/windows/path/to/file.db';
|
||||
|
||||
$manager = Doctrine_Manager::getInstance();
|
||||
|
||||
@ -110,9 +110,9 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase {
|
||||
try {
|
||||
$expectedDsn = array(
|
||||
"scheme" => "sqlite",
|
||||
"host" => null,
|
||||
"path" => "c:/full/windows/path/to/file.db",
|
||||
"dsn" => "sqlite:c:/full/windows/path/to/file.db",
|
||||
"host" => null,
|
||||
"port" => NULL,
|
||||
"user" => null,
|
||||
"pass" => null,
|
||||
|
Loading…
x
Reference in New Issue
Block a user