when defining an ability using createMongoAbility, the authorize hook does not take $exists into consideration. it took me a long time to understand that feathers-casl is responsible for handling this.
Expected behavior
handle $exists for the fields at hook level, not database, which makes it faster and universal.
Actual behavior
throws BadRequest: Invalid query parameter $exists which seems to be working with mongo db only.
edit: I have not confirmed that it works with mongodb, it's just a guess from what it seems
when basic check happens inside authorizeBefore it probably doesn't need to pass $exists to the query, as the $exists is for the incoming request, not the actual data (correct me if I'm wrong)
so we need to clean it up before it reaches the query I guess?
Possible workaround
Simply ignoring using $exists and create an inverted rule restricting the troublesome fields
edit:it seems nothing can replace the $exists operator for making sure that a property is not set
edit2: availableFields plays an important role in making this workaround work, which is fine but not ideal
This issue happens with knex adaptor
when defining an ability using createMongoAbility, the authorize hook does not take
$exists
into consideration. it took me a long time to understand that feathers-casl is responsible for handling this.Expected behavior
handle $exists for the fields at hook level, not database, which makes it faster and universal.
Actual behavior
throws
BadRequest: Invalid query parameter $exists
which seems to be working with mongo db only.edit: I have not confirmed that it works with mongodb, it's just a guess from what it seems
System configuration
More Info
when basic check happens inside authorizeBefore it probably doesn't need to pass $exists to the query, as the $exists is for the incoming request, not the actual data (correct me if I'm wrong)
so we need to clean it up before it reaches the query I guess?
Possible workaround
Simply ignoring usingedit:$exists
and create an inverted rule restricting the troublesome fieldsit seems nothing can replace the $exists operator for making sure that a property is not setedit2:availableFields
plays an important role in making this workaround work, which is fine but not ideal