When browsing to www.example.com/program/session-schedule, the following error displays:

user warning: query: SELECT DISTINCT DATE_FORMAT(s.field_slot_datetime_value, '%Y-%m-%d') AS day FROM content_type_time_slot s INNER JOIN node n ON s.nid = n.nid AND s.vid = n.vid GROUP BY DATE_FORMAT(s.field_slot_datetime_value, '%Y-%m-%d') ORDER BY s.field_slot_datetime_value ASC in /var/vhost/drupal/cod-6.x-1.0-beta1/profiles/cod/modules/contrib/cod_support/cod_session/cod_session.module on line 867.

There are no sessions displayed, even if rooms/time slots are created, and sessions assigned.

The same error appears twice, and also appears here : www.example.com/program/session-schedule/your-schedule

I'm using Drupal 6.19 & Postgres 8.3.

I believe the error is caused because Postgres doesn't have a DATE_FORMAT function.

Having a look at views, this is how they got around it:


switch ($db_type) {
    case 'mysql':
    case 'mysqli':
      $replace = array(
        'Y' => '%Y',
        'm' => '%m',
        'd' => '%%d',
        'H' => '%H',
        'i' => '%i',
        's' => '%s',
        );
      $format = strtr($format, $replace);
      return "DATE_FORMAT($field, '$format')";
    case 'pgsql':
      $replace = array(
        'Y' => 'YYYY',
        'm' => 'MM',
        'd' => 'DD',
        'H' => 'HH24',
        'i' => 'MI',
        's' => 'SS',
        );
      $format = strtr($format, $replace);
      return "TO_CHAR($field, '$format')";
  }

Which is in the views_date_sql_format function.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

maikeru’s picture

FileSize
1.52 KB

Attached a patch that works nicely in Postgres. Also needed to add the 'day' column to the order by clause - Postgres was also complaining about that for some reason.

ezra-g’s picture

Thanks for this patch. I re-rolled it so that it can be easily applied. Setting to "needs review" so others can see and test.

ezra-g’s picture

Status: Active » Needs review
FileSize
1.67 KB
redndahead’s picture

Version: 6.x-1.0-beta1 » 6.x-1.x-dev
Status: Needs review » Reviewed & tested by the community

Other than the whitespace at the beginning this patch looks fine as far as code standards and working on mysql still. I don't use postgres so I can't verify that.

redndahead’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
1.67 KB

And I didn't notice it needed break statements. Also made the mysql code the default and removed white spaces.

greggles’s picture

Issue tags: +PostgreSQL Surge

Tagging to try to get a review. If any postgres folks can confirm the patch in #5 that would be great.

Liam Morland’s picture

Issue tags: +PostgreSQL

Tagging

mrconnerton’s picture

Issue summary: View changes
Status: Needs review » Closed (outdated)