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.
The date_views_argument_handler class causes a syntax error in the query due to a missing table alias in the condition string when using a field that is added via a relationship.
See below timestamp field below.
{code}
(DATE_FORMAT(ADDTIME(FROM_UNIXTIME(.timestamp), SEC_TO_TIME(7200)), '%Y-%m-%d %H:%i:%s') >= '2014-12-15 00:00:00' AND DATE_FORMAT(ADDTIME(FROM_UNIXTIME(.timestamp), SEC_TO_TIME(7200)), '%Y-%m-%d %H:%i:%s') <= '2014-12-22 00:00:00')
{code}
Comment | File | Size | Author |
---|---|---|---|
#3 | date_views-views-argument-correct-table_alias-2395069-3.patch | 1.24 KB | pjcdawkins |
|
Comments
Comment #1
recrit CreditAttribution: recrit commentedCause: Line 168 of date_views_argument_handler.inc, the table is set to the alias returned by "$this->query->ensure_table" after it was set to the field's table_name 3 lines above.
Fix:
* Updated code to use
$this->ensure_my_table()
which sets the table_alias based on the query and relationship. This keeps table un-touched which is set to the field's table_name above it, and provides the table_alias correctly for the parent class to process.* The following condition is no longer needed since the table always is the same as the table_name and ensure_my_table processes the alias for relationships.
field['table_name'] != $this->table || !empty($this->relationship)
Comment #2
Chris Matthews CreditAttribution: Chris Matthews commentedThe 4 year old patch to date_views_argument_handler.inc does not apply to the latest 7.x-2.x-dev and may be too old to reroll, but I went ahead and tagged the issue accordingly.
Comment #3
pjcdawkins CreditAttribution: pjcdawkins at Platform.sh commentedRerolled