jaystack / odata-v4-mongodb

This server component lets you process OData requests over a MongoDB database
30 stars 22 forks source link

Exception while using special characters in expression value #15

Open vijendrasainimetacube opened 4 years ago

vijendrasainimetacube commented 4 years ago

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

MathieuCouette commented 4 years ago

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.

WandererInVoids commented 4 years ago

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