Fix: pgsql compatibility

This commit is contained in:
Laurent Destailleur
2011-07-04 07:36:30 +00:00
parent 3836b1ad16
commit 00d69a5855

View File

@@ -24,7 +24,7 @@
/**
* \file htdocs/lib/databases/pgsql.lib.php
* \brief Fichier de la classe permettant de gerer une base pgsql
* \version $Id$
* \version $Id: pgsql.lib.php,v 1.109 2011/07/04 07:36:30 eldy Exp $
*/
// For compatibility during upgrade
if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '../..');
@@ -1104,7 +1104,7 @@ class DoliDb
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql= "ALTER TABLE ".$table." ADD ".$field_name." ";
$sql .= $field_desc['type'];
if( preg_match("/^[^\s]/i",$field_desc['value']))
if ($field_desc['type'] != 'int' && preg_match("/^[^\s]/i",$field_desc['value']))
$sql .= "(".$field_desc['value'].")";
if (preg_match("/^[^\s]/i",$field_desc['attribute']))
$sql .= " ".$field_desc['attribute'];