diff --git a/framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php
index 94487aae258..8c1789e51b3 100644
--- a/framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php
+++ b/framework/Db/lib/Horde/Db/Adapter/Oracle/Schema.php
@@ -427,14 +427,22 @@ public function changeColumn($tableName, $columnName, $type, $options = array())
return;
}
- $old = $this->typeToSql(
- $column->getType(),
- $column->getType() == 'integer' || is_null($options['limit'])
- ? null
- : $column->getLimit(),
- is_null($options['precision']) ? null : $column->precision(),
- is_null($options['scale']) ? null : $column->scale(),
- is_null($options['unsigned']) ? null : $column->isUnsigned()
+ $columnOptions = array(
+ 'limit' => $column->getLimit(),
+ 'default' => $column->getDefault(),
+ 'null' => $column->isNull()
+ );
+ $old = $this->addColumnOptions(
+ $this->typeToSql(
+ $column->getType(),
+ $column->getType() == 'integer' || is_null($options['limit'])
+ ? null
+ : $column->getLimit(),
+ is_null($options['precision']) ? null : $column->precision(),
+ is_null($options['scale']) ? null : $column->scale(),
+ is_null($options['unsigned']) ? null : $column->isUnsigned()
+ ),
+ $columnOptions
);
$new = $this->typeToSql(
$type,
@@ -443,7 +451,7 @@ public function changeColumn($tableName, $columnName, $type, $options = array())
$options['scale'],
$options['unsigned']
);
- if ($old == $new) {
+ if ($old == $this->addColumnOptions($new, $options)) {
return;
}
diff --git a/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php b/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php
index 14cad085bb9..471674838b1 100644
--- a/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php
+++ b/framework/Db/lib/Horde/Db/Adapter/Sqlite/Schema.php
@@ -283,7 +283,7 @@ public function changeColumn($tableName, $columnName, $type, $options=array())
$defs[] = sprintf('$definition["%s"]->setLimit("%s");', $columnName, $options['limit']);
}
if (isset($options['null'])) {
- $defs[] = sprintf('$definition["%s"]->setNull("%s");', $columnName, $options['null']);
+ $defs[] = sprintf('$definition["%s"]->setNull((bool)%d);', $columnName, $options['null']);
}
if (isset($options['precision'])) {
$defs[] = sprintf('$definition["%s"]->setPrecision("%s");', $columnName, $options['precision']);
diff --git a/framework/Db/package.xml b/framework/Db/package.xml
index 0a9225135a2..2860da5b42e 100644
--- a/framework/Db/package.xml
+++ b/framework/Db/package.xml
@@ -34,7 +34,7 @@
BSD-2-Clause
-*
+* [jan] Fix changing columns to NULL/NOT NULL on Oracle and SQLite.
@@ -800,7 +800,7 @@
2014-05-21
BSD-2-Clause
-*
+* [jan] Fix changing columns to NULL/NOT NULL on Oracle and SQLite.
diff --git a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php
index 58ab9eecf48..3227e05885e 100644
--- a/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php
+++ b/framework/Db/test/Horde/Db/Adapter/Pdo/SqliteTest.php
@@ -46,6 +46,7 @@ protected static function _getConnection($overrides = array())
$cache = new Horde_Cache(new Horde_Cache_Storage_Mock());
$conn->setCache($cache);
+ //$conn->setLogger(new Horde_Log_Logger(new Horde_Log_Handler_Cli()));
return array($conn, $cache);
}
diff --git a/framework/Db/test/Horde/Db/Adapter/TestBase.php b/framework/Db/test/Horde/Db/Adapter/TestBase.php
index 301fbac5550..ba6d45f3382 100644
--- a/framework/Db/test/Horde/Db/Adapter/TestBase.php
+++ b/framework/Db/test/Horde/Db/Adapter/TestBase.php
@@ -430,6 +430,21 @@ abstract public function testChangeColumnLimit();
abstract public function testChangeColumnPrecisionScale();
+ public function testChangeColumnNull()
+ {
+ $this->_createTestTable('sports');
+ $column = $this->_getColumn('sports', 'name');
+ $this->assertTrue($column->isNull());
+ $this->_conn->changeColumn('sports', 'name', 'string',
+ array('null' => false));
+ $column = $this->_getColumn('sports', 'name');
+ $this->assertFalse($column->isNull());
+ $this->_conn->changeColumn('sports', 'name', 'string',
+ array('null' => true));
+ $column = $this->_getColumn('sports', 'name');
+ $this->assertTrue($column->isNull());
+ }
+
abstract public function testRenameColumn();
public function testRenameColumnWithSqlReservedWord()