I am creating a simple events block in Drupal 7 using IIS and SQL Server. I have created a content type of event (title, body, date). I have created a view where I want to display only events that are upcoming. I created a filter that to only display dates that are greater than or equal to today. When I create the filter, I get this error:
SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]Incorrect syntax near '>'.
I have tracked it down, and I see that it is not putting table or column names into part of the where part of the query. Here is the query in the auto query viewer of the view:
SELECT node.[title] AS [node_title], node.[nid] AS [nid], field_data_field_date.[field_date_value] AS [field_data_field_date_field_date_value], 'node' AS field_data_field_date_node_entity_type
FROM
{node} node
LEFT JOIN {field_data_field_date} field_data_field_date ON node.nid = field_data_field_date.entity_id AND (field_data_field_date.entity_type = node AND field_data_field_date.deleted = 0)
WHERE ( (( ([node].[status] = '1') AND ([node].[type] IN ('event')) AND ( >= '2011-06-22') )) )
ORDER BY field_data_field_date_field_date_value DESC
It was posted here: http://drupal.org/node/1185114 (the SQL Server Driver) but they say it isn't their code.
Comments
Comment #1
dawehnerDid you tryed the same view on mysql?
In general you should read the views issue submission guidelines: http://drupal.org/node/571990
They have a lot of valuable informations if you want some real help, for example you should describe what you did, provide an export etc.
Comment #2
jgiboney CreditAttribution: jgiboney commentedI have not tried it in mysql. I do not have a mysql database set up to do this. Here is the view:
Comment #3
dawehnerWhat should be done here ...
You have no mysql server and we don't have a mssql server. Noone can reproduce the bug, that's sad.
Can't you get you one for example with xampp?
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedIt looks like some bug in the Date module filter. I really doubt this is a SQL Server bug.
Comment #5
jgiboney CreditAttribution: jgiboney commentedI used wamp to create a test site. I only downloaded the views, date, and ctools modules. It seems to work fine. So their seem to be three possibilities:
1) We messed up something in our configuration (we didn't do any manually coding)
2) The Views module doesn't play nicely with the SQL Server Driver
3) The Views module in combination with the Date module don't play nicely with the SQL Server Driver
Comment #6
merlinofchaos CreditAttribution: merlinofchaos commentedYou can eliminate date from the equation by trying views that do not use date fields.
If those work, and date fields are the trigger, then date.module is responsible. If things continue to break, date.module is at least not responsible for other fields.
Comment #7
jgiboney CreditAttribution: jgiboney commentedSo I added an integer field to my event content type and did a greater than 2 filter. This worked correctly. Disabling all the date modules doesn't do anything. Disabling the date filter makes the view run correctly.
edit: Disabling doesn't do anything because it just removes the problem field
Comment #8
merlinofchaos CreditAttribution: merlinofchaos commentedThen this is probably a date.module problem, which is not terribly surprising, because all databases handle dates a little bit differently.
Comment #9
dawehnerThis seems to be a duplicate of #1138622: Add support for SQL Server :)
Comment #10
jgiboney CreditAttribution: jgiboney commentedCan anyone tell me the file/function that returns the field names, as this seems to be the only issue?
Comment #11
jgiboney CreditAttribution: jgiboney commentedIf anyone needs a temporary solution, or a starting point to solve this issue, the op_simple function on line 134 of the date_views_filter_handler_simple.inc file in the date > date_views > includes folder is where the where clause is added to the query. I added the following lines after the lines that declare the $field variable:
Comment #12
KarenS CreditAttribution: KarenS commentedFlagging non-MYSQL database issues.
Comment #13
kimberlydb CreditAttribution: kimberlydb commentedI used hook_views_query_alter as a work around to this issue.