From 7f29cd8530b16c04328a506c86dcb336f1539fdf Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Fri, 10 Sep 2010 07:11:22 +0000 Subject: [PATCH] fix for postgreSQL bug reported by Anthony Messina (amessina-at-messinet.com): sync_contentid is varchar(60) and need explicit cast: added egw_db->to_int($expr) --- calendar/setup/tables_update.inc.php | 2 +- phpgwapi/inc/class.egw_db.inc.php | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/calendar/setup/tables_update.inc.php b/calendar/setup/tables_update.inc.php index 34ac4b0ddb..89d4233786 100644 --- a/calendar/setup/tables_update.inc.php +++ b/calendar/setup/tables_update.inc.php @@ -2145,7 +2145,7 @@ function calendar_upgrade1_9_001() ),array( 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true,'bool').' THEN '. '(SELECT '.$GLOBALS['egw_setup']->db->unix_timestamp('sync_deleted'). - " FROM egw_api_content_history WHERE sync_appname='calendar' AND sync_contentid=cal_id)". + " FROM egw_api_content_history WHERE sync_appname='calendar' AND ".$GLOBALS['egw_setup']->db->to_int('sync_contentid').'=cal_id)'. ' ELSE NULL END', )); diff --git a/phpgwapi/inc/class.egw_db.inc.php b/phpgwapi/inc/class.egw_db.inc.php index c893bc6419..6211dba358 100644 --- a/phpgwapi/inc/class.egw_db.inc.php +++ b/phpgwapi/inc/class.egw_db.inc.php @@ -1312,6 +1312,22 @@ class egw_db } return false; } + + /** + * Cast a column or sql expression to integer, necessary at least for postgreSQL + * + * @param string $expr + * @return string + */ + function to_int($expr) + { + switch($this->Type) + { + case 'pgsql': + return $expr.'::integer'; + } + return $expr; + } /** * Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements