diff --git a/cake/libs/model/datasources/dbo/dbo_oracle.php b/cake/libs/model/datasources/dbo/dbo_oracle.php index 0a7b31932..9118d6d10 100644 --- a/cake/libs/model/datasources/dbo/dbo_oracle.php +++ b/cake/libs/model/datasources/dbo/dbo_oracle.php @@ -63,10 +63,10 @@ class DboOracle extends DboSource { * @access public */ var $columns = array( - 'primary_key' => array('name' => 'number NOT NULL'), + 'primary_key' => array('name' => ''), 'string' => array('name' => 'varchar2', 'limit' => '255'), 'text' => array('name' => 'varchar2'), - 'integer' => array('name' => 'numeric'), + 'integer' => array('name' => 'number'), 'float' => array('name' => 'float'), 'datetime' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'), 'timestamp' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'), @@ -74,7 +74,7 @@ class DboOracle extends DboSource { 'date' => array('name' => 'date', 'format' => 'Y-m-d H:i:s'), 'binary' => array('name' => 'bytea'), 'boolean' => array('name' => 'boolean'), - 'number' => array('name' => 'numeric'), + 'number' => array('name' => 'number'), 'inet' => array('name' => 'inet')); /** * Enter description here... @@ -904,6 +904,9 @@ class DboOracle extends DboSource { case 'select': return "SELECT {$fields} FROM {$table} {$alias} {$joins} {$conditions} {$order} {$limit}"; break; + case 'create': + return "INSERT INTO {$table} ({$fields}) VALUES ({$values})"; + break; case 'update': if (!empty($alias)) { $aliases = "{$this->alias}{$alias} "; @@ -916,6 +919,19 @@ class DboOracle extends DboSource { } return "DELETE FROM {$table} {$aliases}{$conditions}"; break; + case 'schema': + foreach (array('columns', 'indexes') as $var) { + if (is_array(${$var})) { + ${$var} = "\t" . join(",\n\t", array_filter(${$var})); + } + } + if (trim($indexes) != '') { + $columns .= ','; + } + return "CREATE TABLE {$table} (\n{$columns}{$indexes})"; + break; + case 'alter': + break; } } /** @@ -1076,5 +1092,27 @@ class DboOracle extends DboSource { } } } + /** + * Generate a "drop table" statement for the given Schema object + * + * @param object $schema An instance of a subclass of CakeSchema + * @param string $table Optional. If specified only the table name given will be generated. + * Otherwise, all tables defined in the schema are generated. + * @return string + */ + function dropSchema($schema, $table = null) { + if (!is_a($schema, 'CakeSchema')) { + trigger_error(__('Invalid schema object', true), E_USER_WARNING); + return null; + } + $out = ''; + + foreach ($schema->tables as $curTable => $columns) { + if (!$table || $table == $curTable) { + $out .= 'DROP TABLE ' . $this->fullTableName($curTable) . "\n"; + } + } + return $out; + } } ?> \ No newline at end of file diff --git a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php index 092c7dbcc..0cacb783c 100644 --- a/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo/dbo_oracle.test.php @@ -36,6 +36,10 @@ require_once LIBS . 'model' . DS . 'datasources' . DS . 'dbo' . DS . 'dbo_oracle * @subpackage cake.tests.cases.libs.model.datasources.dbo */ class DboOracleTest extends CakeTestCase { +/** + * fixtures property + */ + var $fixtures = array('core.oracle_user'); /** * setup method * @@ -86,11 +90,14 @@ class DboOracleTest extends CakeTestCase { } $config = $this->db->config; + $old_pw = $this->db->config['password']; $this->db->config['password'] = 'keepmeout'; $this->db->connect(); $e = $this->db->lastError(); $r = 'ORA-01017: invalid username/password; logon denied'; $this->assertEqual($e, $r); + $this->db->config['password'] = $old_pw; + $this->db->connect(); } /** @@ -124,6 +131,10 @@ class DboOracleTest extends CakeTestCase { $this->assertEqual($e, $r); } + + + + } ?> \ No newline at end of file