Skip to content
Snippets Groups Projects
Commit f08ce6d9 authored by Florian Henry's avatar Florian Henry
Browse files

Fix bug on DDLCreateDb in Mysql

parent 047aa8ea
No related branches found
No related tags found
No related merge requests found
......@@ -884,22 +884,27 @@ class DoliDBMysql
{
$sqlfields[$i] = $field_name." ";
$sqlfields[$i] .= $field_desc['type'];
if( preg_match("/^[^\s]/i",$field_desc['value']))
$sqlfields[$i] .= "(".$field_desc['value'].")";
else if( preg_match("/^[^\s]/i",$field_desc['attribute']))
$sqlfields[$i] .= " ".$field_desc['attribute'];
else if( preg_match("/^[^\s]/i",$field_desc['default']))
if( preg_match("/^[^\s]/i",$field_desc['value'])) {
$sqlfields[$i] .= "(".$field_desc['value'].")";
}
if( preg_match("/^[^\s]/i",$field_desc['attribute'])) {
$sqlfields[$i] .= " ".$field_desc['attribute'];
}
if( preg_match("/^[^\s]/i",$field_desc['default']))
{
if(preg_match("/null/i",$field_desc['default']))
$sqlfields[$i] .= " default ".$field_desc['default'];
else
$sqlfields[$i] .= " default '".$field_desc['default']."'";
if ((preg_match("/null/i",$field_desc['default'])) || (preg_match("/CURRENT_TIMESTAMP/i",$field_desc['default']))) {
$sqlfields[$i] .= " default ".$field_desc['default'];
}
else {
$sqlfields[$i] .= " default '".$field_desc['default']."'";
}
}
if( preg_match("/^[^\s]/i",$field_desc['null'])) {
$sqlfields[$i] .= " ".$field_desc['null'];
}
if( preg_match("/^[^\s]/i",$field_desc['extra'])) {
$sqlfields[$i] .= " ".$field_desc['extra'];
}
else if( preg_match("/^[^\s]/i",$field_desc['null']))
$sqlfields[$i] .= " ".$field_desc['null'];
else if( preg_match("/^[^\s]/i",$field_desc['extra']))
$sqlfields[$i] .= " ".$field_desc['extra'];
$i++;
}
if($primary_key != "")
......
......@@ -876,24 +876,29 @@ class DoliDBMysqli
$i=0;
foreach($fields as $field_name => $field_desc)
{
$sqlfields[$i] = $field_name." ";
$sqlfields[$i] .= $field_desc['type'];
if( preg_match("/^[^\s]/i",$field_desc['value']))
$sqlfields[$i] .= "(".$field_desc['value'].")";
else if( preg_match("/^[^\s]/i",$field_desc['attribute']))
$sqlfields[$i] .= " ".$field_desc['attribute'];
else if( preg_match("/^[^\s]/i",$field_desc['default']))
{
if(preg_match("/null/i",$field_desc['default']))
$sqlfields[$i] .= " default ".$field_desc['default'];
else
$sqlfields[$i] .= " default '".$field_desc['default']."'";
}
else if( preg_match("/^[^\s]/i",$field_desc['null']))
$sqlfields[$i] .= " ".$field_desc['null'];
else if( preg_match("/^[^\s]/i",$field_desc['extra']))
$sqlfields[$i] .= " ".$field_desc['extra'];
$sqlfields[$i] = $field_name." ";
$sqlfields[$i] .= $field_desc['type'];
if( preg_match("/^[^\s]/i",$field_desc['value'])) {
$sqlfields[$i] .= "(".$field_desc['value'].")";
}
if( preg_match("/^[^\s]/i",$field_desc['attribute'])) {
$sqlfields[$i] .= " ".$field_desc['attribute'];
}
if( preg_match("/^[^\s]/i",$field_desc['default']))
{
if ((preg_match("/null/i",$field_desc['default'])) || (preg_match("/CURRENT_TIMESTAMP/i",$field_desc['default']))) {
$sqlfields[$i] .= " default ".$field_desc['default'];
}
else {
$sqlfields[$i] .= " default '".$field_desc['default']."'";
}
}
if( preg_match("/^[^\s]/i",$field_desc['null'])) {
$sqlfields[$i] .= " ".$field_desc['null'];
}
if( preg_match("/^[^\s]/i",$field_desc['extra'])) {
$sqlfields[$i] .= " ".$field_desc['extra'];
}
$i++;
}
if($primary_key != "")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment