Open siddiquipro opened 6 years ago
I too am experiencing duplicate parameters in ODataQuery object when it reaches the controller.
@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.
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.
Is this issue fixed?
I too am experiencing duplicate parameters in ODataQuery object when it reaches the controller.
How did you fix this?
You repo solve the problem, but you have an issue when running npm install
command.
It's running muilpe times.
anli-xsigns Can you describe the fix here?
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.
`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");`