jaystack / odata-v4-server

With JayStack OData v4 Server you can build your own data endpoints without the hassle of implementing any protocol-level code. This framework binds OData v4 requests to your annotated controller functions, and compiles OData v4 compatible response. Clients can access services through OData-compliant HTTP requests. We recommend the JayData library for consuming OData v4 APIs.
https://jaystack.com/products/jaystack-odata-v4-server/
76 stars 55 forks source link

Issues with the $filter, $select and other QueryOperations #33

Open siddiquipro opened 6 years ago

siddiquipro commented 6 years ago

Hello @lazarv

I see some issues with the odata-v4-server ODataQuery, the request query which is received in the controller has duplicated parameters. As a result of duplicate parameters the query generated by odata-v4-sql are incorrect. I feel there is a potential bug in the Visitor class.

Below is the screenshot for reference.

image

`import { odata, ODataController, ODataServer, ODataQuery, Edm } from "odata-v4-server"; import { createQuery, createFilter } from "odata-v4-sql";

export default class employee { @Edm.Key @Edm.Computed @Edm.String id: string; @Edm.String name: string; @Edm.String email: string; @Edm.String department: string; @Edm.String countryCode: string; }

@odata.type(employee) export class EmployeeController extends ODataController { @odata.GET async find(@odata.query query: ODataQuery) { console.log("Query Received in controller - ", query); const sqlQuery = createQuery(query); console.log("SQL Query Returned from odata-v4-sql - ", sqlQuery); return []; } }

@odata.cors @odata.controller(EmployeeController, "employee") export class NorthwindODataServer extends ODataServer {}

NorthwindODataServer.create("/", 3003); console.log("Odata Server Running at / on port 3003");`

jwerra commented 6 years ago

I too am experiencing duplicate parameters in ODataQuery object when it reaches the controller.

jwerra commented 6 years ago

@mohammadsiddiqui @lazarv It looks like https://github.com/jaystack/odata-v4-server/commit/ddb6c1a84f2d6482986e4b791fa75cc4e235d0c5#diff-b9cfc7f2cdf78a7f4b91a753d10865a2 updated deepmerge to a version with breaking changes. The default is now set to concat arrays which is resulting in duplicate parameters.

anli-xsigns commented 6 years ago

I've written a small fix for this, see https://github.com/anli-xsigns/odata-v4-server. You can install the dependency from the git repo, I've made some changes in package.json therefore. If there's interest in a PR I can create one. I've also fixed #35 in that repo.

Rd1819 commented 2 years ago

Is this issue fixed?

Rd1819 commented 2 years ago

I too am experiencing duplicate parameters in ODataQuery object when it reaches the controller.

How did you fix this?

HaithamOumerzoug commented 1 year ago

You repo solve the problem, but you have an issue when running npm install command. It's running muilpe times.

vlatek commented 2 months ago

anli-xsigns Can you describe the fix here?