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

Issues with the $filter, $select and other QueryOperations

Open siddiquipro opened this issue 6 years ago • 7 comments

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");`

siddiquipro avatar Aug 04 '18 04:08 siddiquipro

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

jwerra avatar Aug 20 '18 17:08 jwerra

@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.

jwerra avatar Aug 20 '18 20:08 jwerra

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.

anli-xsigns avatar Nov 07 '18 01:11 anli-xsigns

Is this issue fixed?

Rd1819 avatar Mar 14 '22 09:03 Rd1819

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

How did you fix this?

Rd1819 avatar Mar 14 '22 09:03 Rd1819

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

HaithamOumerzoug avatar Dec 07 '22 10:12 HaithamOumerzoug