Commit ea803566 authored by meus's avatar meus
parent 1945b0d7
...@@ -350,6 +350,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -350,6 +350,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
*/ */
public function parseDsn($dsn) public function parseDsn($dsn)
{ {
//fix linux sqlite dsn so that it will parse correctly
$dsn = str_replace("///", "/", $dsn);
// silence any warnings // silence any warnings
$parts = @parse_url($dsn); $parts = @parse_url($dsn);
...@@ -373,6 +378,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -373,6 +378,11 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
$parts['database'] = ':memory:'; $parts['database'] = ':memory:';
$parts['dsn'] = 'sqlite::memory:'; $parts['dsn'] = 'sqlite::memory:';
} else { } 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['database'] = $parts['path'];
$parts['dsn'] = $parts['scheme'] . ':' . $parts['path']; $parts['dsn'] = $parts['scheme'] . ':' . $parts['path'];
} }
......
...@@ -65,8 +65,8 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase { ...@@ -65,8 +65,8 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase {
// sqlite://full/unix/path/to/file.db // sqlite://full/unix/path/to/file.db
// It expects only // since it thinks it is parsing a url // 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 // The problem after that is that the dns is not valid when being passed to PDO
$sqlite = 'sqlite:/full/unix/path/to/file.db'; $sqlite = 'sqlite:///full/unix/path/to/file.db';
$sqlitewin = 'sqlite:c:/full/windows/path/to/file.db'; $sqlitewin = 'sqlite://c:/full/windows/path/to/file.db';
$manager = Doctrine_Manager::getInstance(); $manager = Doctrine_Manager::getInstance();
...@@ -110,9 +110,9 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase { ...@@ -110,9 +110,9 @@ class Doctrine_Manager_TestCase extends Doctrine_UnitTestCase {
try { try {
$expectedDsn = array( $expectedDsn = array(
"scheme" => "sqlite", "scheme" => "sqlite",
"host" => null,
"path" => "c:/full/windows/path/to/file.db", "path" => "c:/full/windows/path/to/file.db",
"dsn" => "sqlite:c:/full/windows/path/to/file.db", "dsn" => "sqlite:c:/full/windows/path/to/file.db",
"host" => null,
"port" => NULL, "port" => NULL,
"user" => null, "user" => null,
"pass" => null, "pass" => null,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment