Per request, this is a new issue related to http://drupal.org/node/1011852 . When creating a date filter that uses offsets for "greater than" date comparison no results are being returned. Less then comparisons seem to work. I've confirmed that there is data with post dates that should appear. Attached is a screen shot showing configuration.

View code here: http://drupal.pastebin.com/A5VTVSHg
Versions:
- Drupal 7.0
- Views 7.x-3.x-dev
- Ctools 7.x-1.x-dev

Comments

bdragon’s picture

Title: Bug with date handler when comparing using offsets » Date handler offsets broken
Assigned: Unassigned » bdragon
Status: Active » Needs review
StatusFileSize
new1.93 KB

Blame mysql for not erroring on treating a formula as a string. It's silently truncating the offsets because of a bug in the filter handler.

This broke due to the application of #1008706: Convert placeholders to new api.

bdragon’s picture

jcarlson34’s picture

"greater than or equal to" seems to have also been affected. Thanks for working on a fix.

l33tdawg’s picture

Thanks for the fix - spent a good half a day trying to figure out why things weren't working right using Views 7.x-3.0-alpha1

dawehner’s picture

During the codesprint in san jose we fixed a big amount of simpletests. One of this fixes includes the filter_date between part.

It would be cool if someone could tryout the d7v3ui branch and look whether the issue is solved there.

bradjones1’s picture

Patch in #1 works for me.

jimshreds’s picture

Patch #1 not working with latest dev of Views and CTools

bradjones1’s picture

@jimshreds, are you working off a CVS copy of Views dev? It works for me with Ctools 7.x-1.0-alpha2 and Views 7.x-3.x-dev. Which are you on?

jimshreds’s picture

@bradjones1

Views 7.x-3.x-dev
CTools 7.x-1.x-dev

date filters just aren't working. 'greater than' and 'in-between' are the two i rely heavily upon.

bradjones1’s picture

@jimshreds: for what it's worth, you may want to downgrade to CTools 7.x-1.0-alpha2 since the current dev version has a note, "NOT functional yet!"

That said, I'm not a ctools developer and perhaps you need the bleeding-edge version for a specific project. Also I'm not sure this patch would be affected by ctools, anyway, since it looks like the original issue here is a problem with the handling of the filter as a relative date, not just a parseable string.

Can you check to see if the patch is properly applied?

bojanz’s picture

That note is from when the dev version was created.
There's nothing wrong with using a dev version of ctools, it's about to become a release anyway...

jimshreds’s picture

going to be working with a different site that requires the same functionality and will see whats what and report back.

thanks!

dawehner’s picture

Just backported the fix to 7.x-dev.

Can you please tryout the current dev. Therefore you have to wait some time or get the latest version via git.

draganeror’s picture

Subscribe

jimshreds’s picture

updated to current dev and whenever a datehandler field is used the query comes up blank as before.

bojanz’s picture

StatusFileSize
new1.81 KB

Okay, this is still broken in git. I agree with bdragon's patch, rerolled it to apply again.

Give it a test, confirm it works for you, and RTBC.

Note: Without this patch, three assertions fail in the filter tests (offsets, and two for "not between"). After this patch is applied the offset assertion is passing, but not between still isn't.

jimshreds’s picture

should i apply the patch to the git repo or the public dev version?

bojanz’s picture

Today's dev or git are both fine.

jimshreds’s picture

still not working using patched version from git.

bojanz’s picture

StatusFileSize
new3.6 KB

So, NOT BETWEEN was broken.

Fixed it in this reroll, and tweaked the test comments as well.
All tests now pass.

jimshreds’s picture

Strummerville:handlers jim$ patch < 1051308.patch
patching file views_handler_filter_date.inc
Hunk #1 FAILED at 123.
Hunk #2 FAILED at 141.
2 out of 2 hunks FAILED -- saving rejects to file views_handler_filter_date.inc.rej
can't find file to patch at input line 51
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/tests/handlers/views_handler_filter_date.test b/tests/handlers/views_handler_filter_date.test
|index 1ff3acd..d618a7d 100644
|--- a/tests/handlers/views_handler_filter_date.test
|+++ b/tests/handlers/views_handler_filter_date.test
--------------------------
File to patch: views_handler_filter_date.inc
patching file views_handler_filter_date.inc
Hunk #1 FAILED at 2.
Hunk #2 FAILED at 79.
Hunk #3 FAILED at 109.
Hunk #4 FAILED at 174.
4 out of 4 hunks FAILED -- saving rejects to file views_handler_filter_date.inc.rej

bojanz’s picture

Drupal patches since recently need to be applied with patch -p1.
See http://drupal.org/node/1059990

jimshreds’s picture

still getting rejected

patching file views_handler_filter_date.inc
Hunk #1 FAILED at 2.
Hunk #2 FAILED at 79.
Hunk #3 FAILED at 109.
Hunk #4 FAILED at 174.
4 out of 4 hunks FAILED -- saving rejects to file views_handler_filter_date.inc.rej

dawehner’s picture

Alternative wait some time until someone has commited the patch :)

dawehner’s picture

Status: Needs review » Fixed

And commited. Thanks for all the effort.

jimshreds’s picture

INBETWEEN and GREATERTHAN still not functioning after updating.

from the calendar issue queue:
http://drupal.org/node/1077262
"
As KarenS posted somewhere else it is a problem caused by a change of the date handling in views. She said she had to change the way date and calendar interact with views in an massive way. That will be the versions 7.x-2.x-dev when it is quite ready.

"

bojanz’s picture

We fixed it for core handling.
The fact that date or calendar have problems with it is not something we can fix from Views.
Karen meant that Views changed it's Field API integration many times, hence the need to rewrite the code that depends on it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

millaraj’s picture

I seem to be running up against this in 7.9 using rc3.

Trying to filter on a date that is greater than "now", but whilst some rows are returned, they are in the past.

The bizzare thing is, when I used drush to enable the dev views so that I can see the SQL (drush views-dev), the query that is returned, if run directly against the db, returns the correct results. However the preview and the subsequent block, still show items that are in the past.

For info, query that is generated by the view is as follows...

SELECT node.title AS node_title, node.nid AS nid, field_data_field_event_date.field_event_date_value AS field_data_field_event_date_field_event_date_value, 'node' AS field_data_field_event_date_node_entity_type
FROM 
node node
LEFT JOIN field_data_field_event_date field_data_field_event_date ON node.nid = field_data_field_event_date.entity_id AND (field_data_field_event_date.entity_type = 'node' AND field_data_field_event_date.deleted = '0')
WHERE (( (node.status = '1') AND (node.type IN  ('event')) AND (DATE_FORMAT(field_data_field_event_date.field_event_date_value, '%Y-%m-%d\T%H:%i') > '2011-11-29T00:00') ))
ORDER BY field_data_field_event_date_field_event_date_value ASC
LIMIT 10 OFFSET 0

The items that appear in the view, are not in the resultset that is generated by the above view.

Have tried poking around in the views module to see if I can figure it out, but it's so vast I'd need a month just to get my head around it. Hoping that someone more well versed can potentially help out?