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)

This commit is contained in:
Ralf Becker 2010-09-10 07:11:22 +00:00
parent ce35264ed9
commit 7f29cd8530
2 changed files with 17 additions and 1 deletions

View File

@ -2145,7 +2145,7 @@ function calendar_upgrade1_9_001()
),array( ),array(
'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true,'bool').' THEN '. 'cal_deleted' => 'CASE cal_deleted WHEN '.$GLOBALS['egw_setup']->db->quote(true,'bool').' THEN '.
'(SELECT '.$GLOBALS['egw_setup']->db->unix_timestamp('sync_deleted'). '(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', ' ELSE NULL END',
)); ));

View File

@ -1313,6 +1313,22 @@ class egw_db
return false; 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 * Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements
* *