From a1d4a47172f61021db0cfaa2bfda3fac6a951223 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Sun, 27 Jun 2004 09:53:58 +0000 Subject: [PATCH] workaround for a Postgres bug in RefreshTable: unable to find "<" operator for type "unknown", cause by an empty string ('') in a select distinct query --- phpgwapi/inc/class.schema_proc.inc.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/phpgwapi/inc/class.schema_proc.inc.php b/phpgwapi/inc/class.schema_proc.inc.php index c828596054..210c274248 100644 --- a/phpgwapi/inc/class.schema_proc.inc.php +++ b/phpgwapi/inc/class.schema_proc.inc.php @@ -243,23 +243,30 @@ { if ($aDefaults && isset($aDefaults[$name])) // use given default { - $select[] = $aDefaults[$name]; + $value = $aDefaults[$name]; } elseif (isset($old_fd[$name])) // existing column, use its value => column-name in query { - $select[] = $name; + $value = $name; } else // new column => use default value or NULL { if (!isset($data['default']) && (!isset($data['nullable']) || $data['nullable'])) { - $select[] = 'NULL'; + $value = 'NULL'; } else { - $select[] = $this->m_odb->quote(isset($data['default']) ? $data['default'] : '',$data['type']); + $value = $this->m_odb->quote(isset($data['default']) ? $data['default'] : '',$data['type']); + // fix for postgres error "no '<' operator for type 'unknown'" + if ($this->sType == 'pgsql') + { + $type_translated = $this->m_oTranslator->TranslateType($data['type']); + $value = "CAST($value AS $type_translated)"; + } } } + $select[] = $value; } $select = implode(',',$select);