Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#5 | 1237592-d6-2.patch | 1.67 KB | redndahead |
#3 | 1237592-cod-session-postgres.patch | 1.67 KB | ezra-g |
#1 | cod_support.1237592.patch | 1.52 KB | maikeru |
Comments
Comment #1
maikeru CreditAttribution: maikeru commentedAttached 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.
Comment #2
ezra-g CreditAttribution: ezra-g commentedThanks for this patch. I re-rolled it so that it can be easily applied. Setting to "needs review" so others can see and test.
Comment #3
ezra-g CreditAttribution: ezra-g commentedComment #4
redndahead CreditAttribution: redndahead commentedOther 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.
Comment #5
redndahead CreditAttribution: redndahead commentedAnd I didn't notice it needed break statements. Also made the mysql code the default and removed white spaces.
Comment #6
gregglesTagging to try to get a review. If any postgres folks can confirm the patch in #5 that would be great.
Comment #7
Liam MorlandTagging
Comment #8
mrconnerton CreditAttribution: mrconnerton commented