mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-08-17 03:51:21 +02:00
fix for bug #488: Postgres errors when upgrading to 1.4 beta
This commit is contained in:
@ -210,18 +210,21 @@ class ADODB2_postgres extends ADODB_DataDict {
|
||||
{
|
||||
if ($dropflds && !is_array($dropflds)) $dropflds = explode(',',$dropflds);
|
||||
$copyflds = array();
|
||||
foreach($this->MetaColumns($tabname) as $fld) {
|
||||
foreach(($meta=$this->MetaColumns($tabname)) as $fld) {
|
||||
if (!$dropflds || !in_array($fld->name,$dropflds)) {
|
||||
// we need to explicit convert varchar to a number to be able to do an AlterColumn of a char column to a nummeric one
|
||||
if (preg_match('/'.$fld->name.' (I|I2|I4|I8|N|F)/i',$tableflds,$matches) &&
|
||||
in_array($fld->type,array('varchar','char','text','bytea'))) {
|
||||
$copyflds[] = "to_number($fld->name,'S9999999999999D99')";
|
||||
} elseif (preg_match('/'.$fld->name.' ([\w]+)/i',$tableflds,$matches) &&
|
||||
strtoupper($fld->type) != ($type = $this->ActualType($matches[1]))) {
|
||||
$copyflds[] = "CAST($fld->name AS $type)";
|
||||
} else {
|
||||
$copyflds[] = $fld->name;
|
||||
}
|
||||
// identify the sequence name and the fld its on
|
||||
if ($fld->primary_key && $fld->has_default &&
|
||||
preg_match("/nextval\('([^']+)'::text\)/",$fld->default_value,$matches)) {
|
||||
preg_match("/nextval\('([^']+)'::(text|regclass)\)/",$fld->default_value,$matches)) {
|
||||
$seq_name = $matches[1];
|
||||
$seq_fld = $fld->name;
|
||||
}
|
||||
|
Reference in New Issue
Block a user