Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relation filter problem #485

Closed
crisleiria opened this issue Feb 16, 2023 · 5 comments
Closed

Relation filter problem #485

crisleiria opened this issue Feb 16, 2023 · 5 comments

Comments

@crisleiria
Copy link

Hello,

I am getting the same error from this issue #455, but from a dexexpress datagrid. Same scenario kpi table as a one to many relation to section table.

AppServiceProvider.php

Lodata::discoverEloquentModel(Kpi::class);
Lodata::discoverEloquentModel(Section::class);
Lodata::getEntitySet('Kpis')->discoverRelationship('section');

relation on Model Kpi.php

#[LodataRelationship]
public function section()
{
  return $this->belongsTo(Section::class,'section_id');
}

devexpress datasource object

dataSource : {
        store : {
            type : 'odata',
            url : '/odata/kpis',
            key: 'id',
            version : 4,
            beforeSend: function (e) {
                e.headers = {
                    'OData-Version': '4.0',
                };
            },
        },
        expand : ['section']
    }

It work, data is displayed. But when I try to search the name field on section object, I am getting the error:

E4018 - The server has returned a non-numeric value in a response to an item count request. See: http://js.devexpress.com/error/22_2/E4018

And this is the json from server

{
    "@context": "http://localhost:81/odata/$metadata#Kpis",
    "value": [OData-error: {
            "code": "expression_parser_error",
            "message": "Encountered an invalid symbol at: contains(tolower(section/>n<ame),'example')",
            "target": null,
            "details": [],
            "innererror": {}
}

this is the request made by the data grid component

http://localhost:81/odata/Kpis?$filter=contains(tolower(section/name),'example')&$top=0&$count=true

@mgerzabek
Copy link
Contributor

Did you find a solution for that?
To me it looks like your client did not encode the filter for the expanded entity correct. It should be something like

http://localhost:81/odata/Kpis?$filter=section/any(section:contains(tolower(section/name),'example'))&$top=0&$count=true?

@crisleiria
Copy link
Author

Customer decided to remove that column..
I did not explore all datagrid option.. problably was some setting on grid not set.
Without relations it works great.

@mgerzabek
Copy link
Contributor

Hi @crisleiria,
Maybe then it's a good idea to close this issue?

@crisleiria
Copy link
Author

Yes, you can close. If I come back to this, I will report.

@mgerzabek
Copy link
Contributor

Only the owner of the issue, which is you @crisleiria or the owner of the repo can close an issue ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants