-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid oData queries with operators in input filter #650
Comments
I see your point and I would require your help to fix it, you can take a look grid-odata.service.ts, that is where everything happens and the logic was all written by hand. Because it was written by hand, I'm sure that we've missed a few use cases like yours. We also only used OData for 1 project and we moved on to GraphQL some time ago, I also don't have access to an OData Server anymore, so if you could please help that would be really great. Thank you |
Yes, I now see the magic in grid-odata.service.ts - I'll work on a fix. |
I read your description of range inclusive with filter: {
model: Filters.sliderRange,
maxValue: 100, // or you can use the filterOptions as well
operator: OperatorType.rangeInclusive, // defaults to exclusive
filterOptions: { min: 0, step: 5 } as JQueryUiSliderOption // you can also optionally pass any option of the jQuery UI Slider
} So my question to you, does the 3 dots I could switch the default to be inclusive instead of exclusive, it might affect some users but I would prefer to follow the standard defined in the Finance world (Excel). Another thing I could maybe do is to add "Range Inclusive" and "Range Exclusive" in the Compound Filter dropdowns but that would assume the users enters a cell value including dots |
I didn't notice the 3 dots Range exclusive operator: In 'Swift' programming language there exists the concept of a half-open range In Excel (good you mention it!) a range is also inclusive: So to sum up I think it makes more sense to have range inclusive as a default. Also I think a range exclusive option in the input field isn't really needed and it can be confusing that '..' could mean exclusive/inclusive based on |
Ok I can change it to inclusive by default in all Filters
No I don't want to remove it, I needed to change it which is why I added this option, it's fully tested and it would also require lot of code refactoring to remove it in the code and in the unit tests so I'll keep the option, in your case you won't use it and that's fine. |
@jr01 this.gridOptions = {
defaultFilterRangeOperator: OperatorType.rangeInclusive,
}; Cheers ⭐ 🎄 |
This is now fixed and released in the new version Thanks a lot for your contribution in fixing this 😉 Cheers ⭐ |
I'm submitting a Bug report
Your Environment
Describe the Bug
Invalid oData queries are sent when using operators in an input filter.
Steps to Reproduce
case 1
fieldType: number
enter in a number field:
>50.
oData query:
$filter=(amount gt 50.)
Server returns 400
case 2
fieldType: number
enter in a number field:
50..100
oData query:
$filter=(amount gt 50 and amount lt 100)
case 3
fieldType: number
enter in a number field:
50..
oData query:
$filter=(amount gt 50 and amount lt)
Server returns 400
case 4
fieldType: string
enter in a string field:
Bob..Jane
oData query:
$filter=(name gt Bob and name lt Jane)
Server returns 400
case 5
fieldType: string
enter in a string field:
Bob..
oData query:
$filter=(name gt Bob and name lt)
Server returns 400
Expected Behavior
case 1
oData query:
$filter=(amount gt 50)
or$filter=(amount gt 50.0)
case 2
oData query:
$filter=(amount ge 50)
or$filter=(amount ge 50.0)
In my world (financial accounting) most users expect
..
to mean range-inclusive, soge
. Also..
means range inclusive in most programming languages.case 3
oData query:
$filter=(amount ge 50)
case 4
oData query:
$filter=(name ge 'Bob' and name le 'Jane')
The strings Bob and Jane are escaped and range-inclusive is used.
case5
oData query:
$filter=(name ge Bob)
Current Behavior
case 1
Server returns 400
case 2
records with amount=50 and amount=100 aren't returned.
case 3-5
Server returns 400
Possible Solution
case 1
strip
.
case 3
Escape strings when using range operator in string fields.
case 2-5
Change the meaning of
..
to be range-inclusive and usege
andle
. See the arguments above.About range-exclusive: in my mind there is no need to support that at all, a user can just enter the next/previous number. So
50..100
should deliver50,51,....,99,100
and if the user doesn't want 50 or 100 he'll type51..99
.Code Sample
For cases 1 - https://ghiscoding.github.io/angular-slickgrid-demos/#/editor - enter
10..13
in% Complete
- only 1 record is showing - enter10..14
now 3 records are showing and 2 of them have value 13.For cases 2 to 5 - https://ghiscoding.github.io/angular-slickgrid-demos/#/odata
The text was updated successfully, but these errors were encountered: