DateIntervalFilter: Logical Error for filtering custom date
Closed this issue · 19 comments
This is a bug.
Prerequisites
- Are you running the latest version?
- Are you reporting to the correct repository?
(enso is made of many specialized packages: https://github.com/laravel-enso) - Did you check the documentation?
- Did you perform a cursory search?
Description
There is still an issue if you filter custom dates
Steps to Reproduce
- Add a date interval filter
- Switch to custom filter
- Select 2019-02-06 as from
- Select 2019-02-07 as to
Expected behavior
where
`cash_book_entries`.`entry_date` >= '2019-02-06'
and `cash_book_entries`.`entry_date` <= '2019-02-07'
- Filtered result should contain results including from and to date
Actual behavior
where
`cash_book_entries`.`entry_date` >= '2019-02-06'
and `cash_book_entries`.`entry_date` < '2019-02-07'
- Filtered result contains results including from and excluding to
Watch out:
- The filters for e.g. today, yesterday are working correct.
- Compare with #2
I know about this, will take care of it soon.
Will be fixed on 3.6.0 next week
Is this already done?
I saw your entries in the changelog:
- updates date-filter interval logic. Previously, "today" generated an interval between today@00:00:00 (AM) and tomorrow@00:00:00 (AM). Now the interval is between today@00:00:00 and today@23:59:59. The same principle applies for the other intervals.
- dbDateFormat was removed
Date/Timeframe is now correct - but now the output dateFormat is used and not the dbDateFormat?
Yes, it's done
I think you missed my feedback:
Date/Timeframe is now correct - but now the output dateFormat is used and not the dbDateFormat?
In my case date > '31.12.2019'
instead of date > '2019-12-31'
dateFormat specifies the format sent from FE so the be will know how to parse it to Carbon
That's true - but in changelog you wrote:
date interval filters object must now contain the dateFormat prop representing the FE format of the date. If the dateFormat prop is null, the config('enso.config.dateFormat') will be used
If my interval looks like the following:
"entry_date": {
"min": null,
"max": null,
}
I get for today:
`cash_book_entries`.`entry_date` >= '18.10.2019'
and `cash_book_entries`.`entry_date` <= '18.10.2019'
If my interval looks like the following:
"entry_date": {
"min": null,
"max": null,
"dateFormat": 'd.m.Y',
}
I get for today:
`cash_book_entries`.`entry_date` >= '2019-10-18 09:05:20'
and `cash_book_entries`.`entry_date` <= '2019-10-18 09:05:20'
Both looks not correct.
Did I miss something?
Hi mauthi,
It should work if for "dateFormat" you pass a date time format, such as dateFormat:"d-m-Y H:i:s"
.
Aditionally, you can obtain the dateTimeFormat
format from the app state (this.meta.dateTimeFormat
)
If I set that dateFormat to "dateFormat": 'd.m.Y H:i:s'
I get the following exception:
Data missing
Stacktrace:
- /var/www/html/vendor/nesbot/carbon/src/Carbon/Traits/Creator.php:603
- /var/www/html/vendor/laravel-enso/tables/src/app/Services/Data/Filters/Interval.php:62
- /var/www/html/vendor/laravel-enso/tables/src/app/Services/Data/Filters/Interval.php:35
- /var/www/html/vendor/laravel-enso/tables/src/app/Services/Data/Filters/Interval.php:24
- /var/www/html/vendor/laravel/framework/src/Illuminate/Support/Traits/EnumeratesValues.php:176
what's the date format in the requests payload?
d.m.Y
in the intervals object, "dateFormat" is the format for the dates provided by the frontend. You are specifying a format and sending another
In the invervals object I have "dateFormat": 'd.m.Y',
which is the dateFormat I use in frontend.
In the request it sends "entry_date":{"min":"18.10.2019","max":"18.10.2019","dateFormat":"d.m.Y"}}}"
which is IMO also correct?
got it now...
fixed in laravel-enso/tables@3.0.8
I tested it now.
It works when I set dateFormat
in the intervals object but it doesn't work if fallback to enso.config.dateFormat
should be used.
Possible reason in app/Services/Data/Filters/Interval.php
on Line 55:
If dateFormat is not set in request it never uses to the new format() function?
private function value($value, $bound)
{
if (! $value->has('dateFormat')) {
return $value->get($bound);
}
return $value->get($bound)
? Carbon::createFromFormat(
$this->format($value), $value->get($bound)
) : null;
}
Yes I did. We already prepared a new, much cleaner approach for 3.7.0
I guess this is done.