One of drupal view displays reviews based on a selected event. It should display 3 reviews but instead it displays only 2. It doesn't happen for all the events and only for certain events instead of 3 it displays 2 items. As the data is all correct and I have validated the same. I wanted to see the query that is being used. The query that is displayed in the view is not helping me either. If I copy paste the same and run the sql, it throws a lot of error. How can I debug and see what is the query that got executed for that particular view? The view has relationsships and also it uses contextual filters. Thanks
3 Answers
The query displayed in the administration UI contains database prefixing brackets. You can remove those brackets to have valid SQL that can be executed by any SQL client.
-
Yes I tried removing those {} brackets but still its not working.There are few lines like 'field_collection_item' AS field_data_field_art_id_field_collection_item_entity_type, 'node' AS field_data_field_magazine_published_date_node_entity_type, 'node' AS field_data_field_book_review_synopsis_node_entity_type. How does sql interprets it? May 9, 2016 at 16:27
-
Aliasing ("column AS alias") is valid SQL syntax. Without knowing the SQL client error, it's hard to know what it doesn't like about the query. May 10, 2016 at 3:43
The Devel module has a setting that will show all executed queries in the footer.
-
1Yeah, but it keeps the data placeholders. I want to actually see the real query. Mar 8, 2017 at 20:00
You have to use hook_views_pre_execute and with Devel installed use dpq
to view the SQL String:
function hook_views_pre_execute(&$view) {
dpq($view->build_info['query']);
}