-
Notifications
You must be signed in to change notification settings - Fork 1
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
The match filter does not work for string arrays when the value is coercible to another primitive type #1
Comments
@Nexbit things in an array can get complex and not guaranteed to be homogeneous. I think you might really want a custom field. You can use actual field instances in the resource definition Resource.extend({
all_ints: new IntArrayField({default:1})
}); You could also register a field with the built in fields Object.defineProperty(tastypie.fields, 'iarray',{
get: function(){
return IntArrayField;
}
}); then it will work like before Resource.extend({
all_ints: {type:'iarray', default:1}
}); I was also planning on breaking the reql filters out into separate modules so you could tweak them or define new ones as well. Which would also be a good option. Thats what I ended up doing with the bookshelf implementation. |
@Nexbit You could also do per field hydration to clean data on a particular field Resource.extend({
hydrate_extCategories: function( bundle ){
bundle.object.extCategories = bundle.object.extCategories.map((val)=>{
return ~~val;
});
return bundle;
}
}); |
@Nexbit You could also make a special filter type for the use case 'smatch': {
value: function (r, field, term) {
return toField(r, field).contains( "" + term );
}
} |
Yep, I had changed the predefined |
Oh I forgot to mention that the fork is updated for tastypie 3. |
@Nexbit Cool. |
Given the following thinky model:
and the following resource:
If you try to apply a filter like
extCategories__match=123
it does not work as expected, because in the filter implementation:term
is a number and not a string, so the ReQl query does not return any result even if there are documents containing "123" in extCategories array.The only elegant way (IMHO) to resolve this issue is to add an array type option to node-tastypie (see https://github.com/esatterwhite/node-tastypie/issues/14), and to force casting the filter value before applying the filter.
The text was updated successfully, but these errors were encountered: