Commit de220fa4 authored by ppetermann's avatar ppetermann

found a few bugs when i wanted to use Doctrine_Import_Mysql::listTableConstraints()

fixed code so those problems wont occure. However the method still not works as intended, 
more information see mail at doctrine-dev mailinglist.
Fixed same Problems in other drivers aswell.
parent d631c789
...@@ -157,8 +157,8 @@ class Doctrine_Import_Mssql extends Doctrine_Import ...@@ -157,8 +157,8 @@ class Doctrine_Import_Mssql extends Doctrine_Import
{ {
$keyName = 'INDEX_NAME'; $keyName = 'INDEX_NAME';
$pkName = 'PK_NAME'; $pkName = 'PK_NAME';
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE) { if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_FIX_CASE) {
if ($this->conn->options['field_case'] == CASE_LOWER) { if ($this->conn->getAttribute(Doctrine::ATTR_FIELD_CASE) == CASE_LOWER) {
$keyName = strtolower($keyName); $keyName = strtolower($keyName);
$pkName = strtolower($pkName); $pkName = strtolower($pkName);
} else { } else {
......
...@@ -37,7 +37,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import ...@@ -37,7 +37,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
'listSequences' => 'SHOW TABLES', 'listSequences' => 'SHOW TABLES',
'listTables' => 'SHOW TABLES', 'listTables' => 'SHOW TABLES',
'listUsers' => 'SELECT DISTINCT USER FROM USER', 'listUsers' => 'SELECT DISTINCT USER FROM USER',
'listViews' => "SHOW FULL TABLES %sWHERE Table_type = 'VIEW'", 'listViews' => "SHOW FULL TABLES %s WHERE Table_type = 'VIEW'",
); );
/** /**
...@@ -54,7 +54,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import ...@@ -54,7 +54,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
} }
$tableNames = $this->conn->fetchColumn($query); $tableNames = $this->conn->fetchColumn($query);
return array_map(array($this->conn, 'fixSequenceName'), $tableNames); return array_map(array($this->conn->formatter, 'fixSequenceName'), $tableNames);
} }
/** /**
...@@ -68,7 +68,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import ...@@ -68,7 +68,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
$keyName = 'Key_name'; $keyName = 'Key_name';
$nonUnique = 'Non_unique'; $nonUnique = 'Non_unique';
if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_FIX_CASE) { if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_FIX_CASE) {
if ($this->conn->options['field_case'] == CASE_LOWER) { if ($this->conn->getAttribute(Doctrine::ATTR_FIELD_CASE) == CASE_LOWER) {
$keyName = strtolower($keyName); $keyName = strtolower($keyName);
$nonUnique = strtolower($nonUnique); $nonUnique = strtolower($nonUnique);
} else { } else {
...@@ -85,7 +85,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import ...@@ -85,7 +85,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
foreach ($indexes as $indexData) { foreach ($indexes as $indexData) {
if ( ! $indexData[$nonUnique]) { if ( ! $indexData[$nonUnique]) {
if ($indexData[$keyName] !== 'PRIMARY') { if ($indexData[$keyName] !== 'PRIMARY') {
$index = $this->conn->fixIndexName($indexData[$keyName]); $index = $this->conn->formatter->fixIndexName($indexData[$keyName]);
} else { } else {
$index = 'PRIMARY'; $index = 'PRIMARY';
} }
...@@ -159,8 +159,8 @@ class Doctrine_Import_Mysql extends Doctrine_Import ...@@ -159,8 +159,8 @@ class Doctrine_Import_Mysql extends Doctrine_Import
{ {
$keyName = 'Key_name'; $keyName = 'Key_name';
$nonUnique = 'Non_unique'; $nonUnique = 'Non_unique';
if ($this->conn->options['portability'] & Doctrine::PORTABILITY_FIX_CASE) { if ($this->conn->getAttribute(Doctrine::ATTR_PORTABILITY) & Doctrine::PORTABILITY_FIX_CASE) {
if ($this->conn->options['field_case'] == CASE_LOWER) { if ($this->conn->getAttribute(Doctrine::ATTR_FIELD_CASE) == CASE_LOWER) {
$keyName = strtolower($keyName); $keyName = strtolower($keyName);
$nonUnique = strtolower($nonUnique); $nonUnique = strtolower($nonUnique);
} else { } else {
...@@ -176,7 +176,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import ...@@ -176,7 +176,7 @@ class Doctrine_Import_Mysql extends Doctrine_Import
$result = array(); $result = array();
foreach ($indexes as $indexData) { foreach ($indexes as $indexData) {
if ($indexData[$nonUnique] && ($index = $this->conn->fixIndexName($indexData[$keyName]))) { if ($indexData[$nonUnique] && ($index = $this->conn->formatter->fixIndexName($indexData[$keyName]))) {
$result[] = $index; $result[] = $index;
} }
} }
......
...@@ -108,7 +108,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import ...@@ -108,7 +108,7 @@ class Doctrine_Import_Sqlite extends Doctrine_Import
$result = array(); $result = array();
foreach ($indexes as $sql) { foreach ($indexes as $sql) {
if (preg_match("/^create unique index ([^ ]+) on /i", $sql, $tmp)) { if (preg_match("/^create unique index ([^ ]+) on /i", $sql, $tmp)) {
$index = $this->conn->fixIndexName($tmp[1]); $index = $this->conn->formatter->fixIndexName($tmp[1]);
if ( ! empty($index)) { if ( ! empty($index)) {
$result[$index] = true; $result[$index] = true;
} }
......
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