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.
Steps to reproduce
1.Create a content type with node referenced field.
2.Create View of block type for the new content type.
3.Set a contextual filter on node referenced field.
4.Try to enter an id into "Preview with contextual filters:" field
5.Click "Update preview"
Error
"SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS field_data_field_rating_, node.uid AS node_uid, node.created AS node_created,' at line 1"
Comments
Comment #1
sambonner CreditAttribution: sambonner commentedCan confirm this is an issue for me in views-7.x-3.6. Rolling back to 3.5 brings the views back.
Have tested on 3.7 and 3.x-dev and the issue is present on both. Running drupal 7.21.
Any solutions available for this, as it stands I cannot run the latest views security release due to this problem.
Comment #2
Thangobrind CreditAttribution: Thangobrind commentedsubscribe
Comment #3
Mołot CreditAttribution: Mołot commentedIf it was working in past, it deserve regression tag.
Would you care to provide full SQL generated by views? I'm not so fluent with views arcana, but not bad on SQL level, maybe I'll be able to get some idea what's wrong.
Comment #4
xmacinfoI do have the same type of error when using the aggregation feature of Views:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS field_data_field_geolocation_, field_data_field_office_telephone.field_office' at line 1
The AS part is truncating the field name:
AS field_data_field_geolocation_,
Yes, in that example I am using the addressfield and geolocation modules.
To fix you need to delete and add again the field (here geolocation), and select some columns.
Comment #5
radiobuzzer CreditAttribution: radiobuzzer commentedI confirm that when Aggregation is enabled, somehow the argument of the AS clause are truncated, resulting into an invalid SQL query. Here is my example:
Before aggregation
After aggregation
Error given
I am also using field collections as you can see
Comment #6
alphex CreditAttribution: alphex commentedI'm having this issue also, but the only things different between my dev box (where it works) and production (where I'm seeing the problem), are the MYSQL versions.
Dev = PHP 5.3.10-1ubuntu3.6 && MYSQL 5.5.31-0ubuntu0.12.04.2
Prod = PHP 5.3.2-1ubuntu4.11 && MYSQL 5.1.41-3ubuntu12.10
Comment #7
capellicI was hoping that reverting from 3.5 to 3.7 would fix the issue, but I'm still having the problem:
Comment #8
siramsay CreditAttribution: siramsay commentedIssue persists, trying to use aggregation
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS field_data_field_upload_image_, field_data_field_campaign_staff_pick.field_ca' at line 1
Comment #9
siramsay CreditAttribution: siramsay commentedjust marking it as a duplicate of https://www.drupal.org/node/1809584 Turning aggregation on with existing image fields fails with SQLSTATE[42000]
#6 in that thread fixed the problem