Given the following definition in hook_views_data:
$data['Contest_Status']['ContestStatusName'] = array(
'title' => t('Contest Status'),
'help' => t('The status of the contest, Open/Reserved/etc.'),
'field' => array(
'handler' => 'views_handler_field',
),
);
Views will load the data from Contest_Status.ContestStatusName into $view->result properly, in the following format:
(object)->contest_status_conteststatusname = "open"
However, views_handler_field->field_alias is set to "Contest_Status_ContestStatusName".
While there are no visible error messages, this (or something related) causes the field to be rendered empty. Change the table/column names to lowercase in the database and hook_views_data fixes the problem.
This is obviously only a problem when interacting with an external database, since Drupal lowercases all its table names, but it is none-the-less a bug.
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | 1133924-lowercase-all-field-aliases.patch | 575 bytes | merlinofchaos |
Comments
Comment #1
threewestwinds commentedThe fix is very simple: views_handler_field.inc, line 65 from
$this->field_alias = $this->query->add_field($this->table_alias, $this->real_field, NULL, $params);into
$this->field_alias = strtolower($this->query->add_field($this->table_alias, $this->real_field, NULL, $params));I'll have time to turn this quickfix into a proper git patch later this week, of someone doesn't beat me to the punch. Very, very busy right now with a deadline.
Note that I have not tried this on different databases, so it may not be an issue except on my particular configuration. MySQL 4.1.22, PHP extension: mysql
Comment #2
merlinofchaos commented'needs work' will bury this.
Need to figure out where the lowercasing problem really arises. Could be dbtng. I suppose it could be necessary ot just lowercase any alias we get in the query object.
Marking this as minor; it is a bug but it's going to affect very, very few.
Comment #3
threewestwinds commentedYou're right that this is definitely an edge case.
It turns out that lowercasing table and column names before returning them is intentional in dbtng, for consistency (#337926: Force connection with PDO::CASE_LOWER). Given that, I think you're right that the correct solution is to force all aliases into lowercase.
Comment #4
threewestwinds commentedI believe the correct place to lowercase aliases is in the query builder, so that the database side and PHP side always match (rather than lowercasing on data retrieval). views_plugin_query_default.inc creates aliases in six separate places (lines 146, 409, 462, 742, 767, 973). strtolower() on these lines fixes the problem as well.
In a completely bizarre, but apparently related, bug, the javascript for Views UI decides to hide several form elements when uppercased table of column names are involved (see attached screenshot - the second one is with javascript disabled). Some piece of javascript is setting "display:none" on the containing div.
I know this is related to uppercase table/column names because if I modify my schema and hook_views_data to lowercase (changing nothing else) the form elements remain visible.
Note that all the hidden elements do function properly. Click-sorting works fine, with and without AJAX. But to turn it on or modify settings, I have to either disable javascript or make the elements visible by hand... this tidbit has me really scratching my head.
Comment #5
merlinofchaos commentedFor the unrelated bug, try latest CTools -dev. #dependency being aggressive.
Comment #6
threewestwinds commentedI was running the ctools-dev from the 13th, and upgrading to the most recent (as of right now) had no effect. ctools/views is still hiding the form elements.
Comment #7
dawehnerOh the latest dev probably means from today/yesterday. Perhaps drupal.org doesn't have rebuilt the dev release yet.
Comment #8
merlinofchaos commentedThis patch should fix the problem.
Comment #9
fadeddata commentedThis patch is working for me.
Comment #10
merlinofchaos commentedCommitted. Thanks for testing!