-
Notifications
You must be signed in to change notification settings - Fork 213
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
Performance issue, readability and extension proposals toOdataString #2102
Comments
As from Odata 4.0.1 the in function can be used (so select multiple values - and by multiple i mean > 20 :) To support operator $field in ($value1, ...$valueN) i had to patch some functions (beyond those described above). Yet due to OData impl. there are some limitations:
Filter sample:
Patches:
|
Proof of extensibility due refactorRecent refactor changes on the compositeFilterSerializationFn includes the move the inner part to a separate, reusable serializeFilterFn function. The name although reminds the main entry function serializeFilter (which I dislike) - but currently still trying to keep kendo naming...
This change allowed me to create additional filter operators:
|
:) Wow, what a proposal. @hidegh And not a response until now? |
@EricSch actually they got everything, yet no response. if they would ask, I probably would be allowed to give over the working code (so-so it's almost in fully described here). internally we already use the extended toOdataStringEx, all those extras helped us to achieve cleaner custom filter design (NoopFilterDescriptorEx), easier search inside inner collections, etc. etc. So here is an another small code that was necessary for creating complex custom filters. We had to wrap the filter into a NoopFilterDescriptorEx so the UI could do a match based on field name - and thus we also modified the originaly NegationOperatorDescriptorEx that I posted in the past. New code below:
|
Thank you for proposals and code samples. We reviewed all suggestions again, and decided to address them as follows:
|
PROPOSALS
Up to now, despite all changes the modified toOdataStringEx did not include any breaking changes to existing code! Would consider some extension point via the ODataSettingEx, so that we'd avoid the changes inside implementation.
Performance, readability & extensibility issues
When working with KENDO Angular and OData, I've found the original implementation quiet limiting, so when I was reading the source found some issues:
-- had to change some of the original transformation functions to add extra parameter
-- and/or had to change the original transformation function to avoid parameter deconstruction and to avoid the use of immutables (this needed from me to do create a copy of State object before doing any calculation, also fixing the multiple execution - see rule vs ruleFn -, but afterwards enriching objects inside State and use those extra parameters inside my own toOdataStringEx was possible)
OData serializeKey simplification
NEW:
const serializeKey = (keys, value) => isPresent(value) ? keys[0] + value : '';
ORIGINAL:
COMMENT:
No, it's not a violation of DRY, it's about readability.
IMPORTANT:
An internal refactor and an Fn suffix for those parameters that are expected to be functions, like:
const eitherFn = (predicateFn, rightFn, leftFn) => value => predicateFn(value) ? rightFn(value) : leftFn(value);
...could HELP A BIT with readability, even if interfaces when CURRYING is used is not as helpful as seeing the implementation itself (in our case the: predicateFn(value) ? rightFn(value) : leftFn(value);
...so either(isPresent, concat(strings[0]), emptyString)(val) is not saying much, without that!
Interface for either: (predicate, right, left): (value: any) => any
OData serializeFilter - simplification around serializeAll
COMMENT:
- It's just removing one extra function
- NOT USING CURRYING UNNECESSARILY inside map and join
- making it READABLE
- adding some type-safety checks
NEW:
ORIGINAL:
OData serialzer - rules - optimization
Since const rules is an object from which we take one property (via key), all the 4 functions are evaluated when object is requested.
Changing property values to functions we can avoid the call to the serialize*** functions, resulting in the execution of just teh selection.
NEW CODE CHANGES:
Fixing field normalizers in eq/neq empty/null and simplifying doesnotcontain...
...by introducing const fieldFnExpression = (expression) => ({ field }) =>
${field} ${expression}
instead of appendEquals and replacing filter operatorsFurther extensions & limitations:
In short, following changes were introduced in my custom solution:
My global settings
The text was updated successfully, but these errors were encountered: