While using the latest version of Calendar and the Date module I came across the following SQL errors:

    * warning: pg_query() [function.pg-query]: Query failed: ERROR: invalid input syntax for type reltime: "INTERVAL -14400 SECONDS" in /home/anthony/domains/anthony.thrillist-dev.com/public_html/thrillist2.0/includes/database.pgsql.inc on line 125.
    * user warning: query: SELECT node.nid, node_data_field_date.field_date_value || '|' || node_data_field_date.field_date_value AS node_data_field_date_field_date_value, node.type FROM node node LEFT JOIN content_type_piece node_data_field_date ON node.vid = node_data_field_date.vid WHERE (node.type IN ('piece')) AND (((node_data_field_date.field_date_value::ABSTIME + 'INTERVAL -14400 SECONDS') >= '2008-08-01 00:00:00' AND (node_data_field_date.field_date_value::ABSTIME + 'INTERVAL -14400 SECONDS') <= '2008-08-31 23:59:59')) ORDER BY node_data_field_date_field_date_value ASC in /home/anthony/domains/anthony.thrillist-dev.com/public_html/thrillist2.0/includes/database.pgsql.inc on line 144.

I traced it back to the code as follows:

 /**
   * Adjust a field value by an offset in seconds.
   */
  function sql_offset($field, $offset = NULL) {
    if (!empty($offset)) {
      switch ($this->db_type) {
        case 'mysql':
        case 'mysqli':
          return "ADDTIME($field, SEC_TO_TIME($offset))";
        case 'pgsql':
          return "($field + 'INTERVAL $offset SECONDS')";;
      }
    }
    return $field;
  }

This is incorrect and makes PostgreSQL crash. The apostrophe should be at the beginning of offset, here is my rewritten case statement:

        case 'pgsql':
          return "($field + INTERVAL '$offset SECONDS')";

Hope someone can make a patch of this as I don't know how to.

Good luck!

Comments

karens’s picture

Status: Active » Fixed

Committed. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.