aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/db/tools.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2014-06-25 13:40:32 +0200
committerJoas Schilling <nickvergessen@gmx.de>2014-06-25 13:40:32 +0200
commit95ab4b3e931521ce3c56068478311f0c04f713cc (patch)
treea6d591cb2d81abd0de9e72292e0e0afe0e1d0f4b /phpBB/phpbb/db/tools.php
parent3e9d62b9b08691f38f53eb79cdac3698a108a46b (diff)
downloadforums-95ab4b3e931521ce3c56068478311f0c04f713cc.tar
forums-95ab4b3e931521ce3c56068478311f0c04f713cc.tar.gz
forums-95ab4b3e931521ce3c56068478311f0c04f713cc.tar.bz2
forums-95ab4b3e931521ce3c56068478311f0c04f713cc.tar.xz
forums-95ab4b3e931521ce3c56068478311f0c04f713cc.zip
[ticket/12448] Allow null as default value for columns
PHPBB3-12448
Diffstat (limited to 'phpBB/phpbb/db/tools.php')
-rw-r--r--phpBB/phpbb/db/tools.php31
1 files changed, 25 insertions, 6 deletions
diff --git a/phpBB/phpbb/db/tools.php b/phpBB/phpbb/db/tools.php
index 2ec46ed239..874fe4dc11 100644
--- a/phpBB/phpbb/db/tools.php
+++ b/phpBB/phpbb/db/tools.php
@@ -1487,8 +1487,16 @@ class tools
$return_array['textimage'] = $column_type === '[text]';
- $sql .= 'NOT NULL';
- $sql_default .= 'NOT NULL';
+ if (!is_null($column_data[1]))
+ {
+ $sql .= 'NOT NULL';
+ $sql_default .= 'NOT NULL';
+ }
+ else
+ {
+ $sql .= 'NULL';
+ $sql_default .= 'NULL';
+ }
$return_array['column_type_sql_default'] = $sql_default;
@@ -1503,7 +1511,15 @@ class tools
{
$sql .= (strpos($column_data[1], '0x') === 0) ? "DEFAULT {$column_data[1]} " : "DEFAULT '{$column_data[1]}' ";
}
- $sql .= 'NOT NULL';
+
+ if (!is_null($column_data[1]))
+ {
+ $sql .= 'NOT NULL';
+ }
+ else
+ {
+ $sql .= 'NULL';
+ }
if (isset($column_data[2]))
{
@@ -1528,7 +1544,7 @@ class tools
// Oracle does not like setting NOT NULL on a column that is already NOT NULL (this happens only on number fields)
if (!preg_match('/number/i', $column_type))
{
- $sql .= ($column_data[1] === '') ? '' : 'NOT NULL';
+ $sql .= ($column_data[1] === '' || $column_data[1] === null) ? '' : 'NOT NULL';
}
$return_array['auto_increment'] = false;
@@ -1588,8 +1604,11 @@ class tools
$sql .= ' ' . $column_type;
}
- $sql .= ' NOT NULL ';
- $sql .= (!is_null($column_data[1])) ? "DEFAULT '{$column_data[1]}'" : '';
+ if (!is_null($column_data[1]))
+ {
+ $sql .= ' NOT NULL ';
+ $sql .= "DEFAULT '{$column_data[1]}'";
+ }
break;
}