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(
'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',
));

View File

@ -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