From a8ddeb719d263608259844872ff26f08358832a6 Mon Sep 17 00:00:00 2001 From: Carsten Wolff Date: Thu, 27 Sep 2007 22:07:28 +0000 Subject: [PATCH] explicitly enable casts between text and bytea for transparent use by schema_proc --- phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php b/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php index 963e96b2ed..ea5c09dafe 100644 --- a/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php +++ b/phpgwapi/inc/adodb/datadict/datadict-postgres.inc.php @@ -218,7 +218,13 @@ class ADODB2_postgres extends ADODB_DataDict { $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)"; + if ($type == 'BYTEA' && $fld->type == 'text') { + $copyflds[] = "DECODE($fld->name, 'escape')"; + } elseif ($fld->type == 'bytea' && $type == 'TEXT') { + $copyflds[] = "ENCODE($fld->name, 'escape')"; + } else { + $copyflds[] = "CAST($fld->name AS $type)"; + } } else { $copyflds[] = $fld->name; } @@ -360,4 +366,4 @@ CREATE [ UNIQUE ] INDEX index_name ON table return $sql; } } -?> \ No newline at end of file +?>