PostgreSQL needs more casts / abstraction to fix SQL error

contact_id/account_id are int, but cal_user_id is varchar
This commit is contained in:
Ralf Becker 2019-01-18 10:47:46 +01:00
parent 1729a9dda2
commit 668ba6f632

View File

@ -1698,6 +1698,7 @@ class Contacts extends Contacts\Storage
$calendars = array(); $calendars = array();
$bocal = new calendar_bo(); $bocal = new calendar_bo();
$type_field = $type=='u' ? 'account_id' : 'contact_id'; $type_field = $type=='u' ? 'account_id' : 'contact_id';
$type_field_varchar = $this->db->to_varchar($type_field);
$concat_start_id_recurrance = $this->db->concat('cal_start',"':'",'egw_cal_user.cal_id',"':'",'cal_recur_date'); $concat_start_id_recurrance = $this->db->concat('cal_start',"':'",'egw_cal_user.cal_id',"':'",'cal_recur_date');
$now = $this->db->unix_timestamp('NOW()'); $now = $this->db->unix_timestamp('NOW()');
$sql = "SELECT n_fn,org_name,$type_field AS user_id, $sql = "SELECT n_fn,org_name,$type_field AS user_id,
@ -1706,7 +1707,7 @@ class Contacts extends Contacts\Storage
FROM egw_cal_user FROM egw_cal_user
JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start) JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start)
JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL
WHERE cal_user_type='$type' and cal_user_id=$type_field and cal_start < $now"; WHERE cal_user_type='$type' and cal_user_id=$type_field_varchar and cal_start < $now";
if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected']) if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])
{ {
$sql .= " AND egw_cal_user.cal_status != 'R'"; $sql .= " AND egw_cal_user.cal_status != 'R'";
@ -1719,7 +1720,7 @@ class Contacts extends Contacts\Storage
FROM egw_cal_user FROM egw_cal_user
JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start) JOIN egw_cal_dates on egw_cal_dates.cal_id=egw_cal_user.cal_id and (cal_recur_date=0 or cal_recur_date=cal_start)
JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL JOIN egw_cal ON egw_cal.cal_id=egw_cal_user.cal_id AND egw_cal.cal_deleted IS NULL
WHERE cal_user_type='$type' and cal_user_id=$type_field and cal_start > $now"; WHERE cal_user_type='$type' and cal_user_id=$type_field_varchar and cal_start > $now";
if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected']) if ( !$GLOBALS['egw_info']['user']['preferences']['calendar']['show_rejected'])
{ {
$sql .= " AND egw_cal_user.cal_status != 'R'"; $sql .= " AND egw_cal_user.cal_status != 'R'";