Skip to content
Permalink
Browse files

PostgreSQL needs more casts / abstraction to fix SQL error

contact_id/account_id are int, but cal_user_id is varchar
  • Loading branch information...
ralfbecker committed Jan 18, 2019
1 parent 1729a9d commit 668ba6f6323c76046694e34ab0e0f1d257a9dfce
Showing with 3 additions and 2 deletions.
  1. +3 −2 api/src/Contacts.php
@@ -1698,6 +1698,7 @@ private function read_calendar_type($uids, $type='c', $extra_title = true)
$calendars = array();
$bocal = new calendar_bo();
$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');
$now = $this->db->unix_timestamp('NOW()');
$sql = "SELECT n_fn,org_name,$type_field AS user_id,
@@ -1706,7 +1707,7 @@ private function read_calendar_type($uids, $type='c', $extra_title = true)
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 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'])
{
$sql .= " AND egw_cal_user.cal_status != 'R'";
@@ -1719,7 +1720,7 @@ private function read_calendar_type($uids, $type='c', $extra_title = true)
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 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'])
{
$sql .= " AND egw_cal_user.cal_status != 'R'";

0 comments on commit 668ba6f

Please sign in to comment.
You can’t perform that action at this time.