odata-v4-mongodb icon indicating copy to clipboard operation
odata-v4-mongodb copied to clipboard

Exception while using special characters in expression value

Open vijendrasainimetacube opened this issue 5 years ago • 2 comments

Hi, I am getting exception while using '/' in expression value. for example:

var query = createQuery("$filter=status ne 'FIXED/RESOLVED'");

Error: Unexpected character at 14$filter=status ne 'FIXED/RESOLVED' at D:\workspace\AmeriGas\API-Server\api-server\node_modules\odata-v4-parser\lib\parser.js:25:19 at Object.query (D:\workspace\AmeriGas\API-Server\api-server\node_modules\odata-v4-parser\lib\parser.js:45:93) at createQuery (D:\workspace\AmeriGas\API-Server\api-server\node_modules\odata-v4-mongodb\lib\index.js:6:66)

Thanks

vijendrasainimetacube avatar May 15 '20 08:05 vijendrasainimetacube

It's somewhat complicated, but my understanding is that the module expects the parameter names ($filter, in this case) and the parameter values (status ne 'FIXED/RESOLVED', in this case) to be URI encoded. You can use encodeURIComponent function to do that.

Keep in mind that the module currently has a bug that prevents the usage of URI encoded date times.

MathieuCouette avatar Jun 02 '20 01:06 MathieuCouette

i create package with fix https://github.com/WandererInVoids/odata-v4-mongodb https://www.npmjs.com/package/@wandererin/odata-v4-mongodb

WandererInVoids avatar Sep 01 '20 13:09 WandererInVoids