diff --git a/modules/comment/views_handler_field_ncs_last_updated.inc b/modules/comment/views_handler_field_ncs_last_updated.inc index d1d7306..47c7d16 100644 --- a/modules/comment/views_handler_field_ncs_last_updated.inc +++ b/modules/comment/views_handler_field_ncs_last_updated.inc @@ -13,6 +13,7 @@ class views_handler_field_ncs_last_updated extends views_handler_field_date { function query() { $this->ensure_my_table(); $this->node_table = $this->query->ensure_table('node', $this->relationship); - $this->field_alias = $this->query->add_field(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->table_alias . ".last_comment_timestamp)", $this->table_alias . '_' . $this->field); + $comparison = "(CASE WHEN " . $this->node_table . ".changed > " . $this->table_alias . ".last_comment_timestamp THEN " . $this->node_table . ".changed ELSE " . $this->table_alias . ".last_comment_timestamp END)"; + $this->field_alias = $this->query->add_field(NULL, $comparison, $this->table_alias . '_' . $this->field); } } diff --git a/modules/comment/views_handler_filter_ncs_last_updated.inc b/modules/comment/views_handler_filter_ncs_last_updated.inc index 2319edf..1ba2dfe 100644 --- a/modules/comment/views_handler_filter_ncs_last_updated.inc +++ b/modules/comment/views_handler_filter_ncs_last_updated.inc @@ -14,9 +14,7 @@ class views_handler_filter_ncs_last_updated extends views_handler_filter_date { function query() { $this->ensure_my_table(); $this->node_table = $this->query->ensure_table('node', $this->relationship); - - $field = "GREATEST(" . $this->node_table . ".changed, " . $this->table_alias . ".last_comment_timestamp)"; - + $field = "(CASE WHEN " . $this->node_table . ".changed > " . $this->table_alias . ".last_comment_timestamp THEN " . $this->node_table . ".changed ELSE " . $this->table_alias . ".last_comment_timestamp END)"; $info = $this->operators(); if (!empty($info[$this->operator]['method'])) { $this->{$info[$this->operator]['method']}($field); diff --git a/modules/comment/views_handler_sort_ncs_last_updated.inc b/modules/comment/views_handler_sort_ncs_last_updated.inc index 83f0f54..aa3714d 100644 --- a/modules/comment/views_handler_sort_ncs_last_updated.inc +++ b/modules/comment/views_handler_sort_ncs_last_updated.inc @@ -14,6 +14,7 @@ class views_handler_sort_ncs_last_updated extends views_handler_sort_date { function query() { $this->ensure_my_table(); $this->node_table = $this->query->ensure_table('node', $this->relationship); - $this->field_alias = $this->query->add_orderby(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->table_alias . ".last_comment_timestamp)", $this->options['order'], $this->table_alias . '_' . $this->field); + $comparison = "(CASE WHEN " . $this->node_table . ".changed > " . $this->table_alias . ".last_comment_timestamp THEN " . $this->node_table . ".changed ELSE " . $this->table_alias . ".last_comment_timestamp END)"; + $this->field_alias = $this->query->add_orderby(NULL, $comparison, $this->options['order'], $this->table_alias . '_' . $this->field); } }