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

Property named "true" in $select throws exception #2410

Open
giulianob opened this issue May 19, 2022 · 6 comments · May be fixed by #2437
Open

Property named "true" in $select throws exception #2410

giulianob opened this issue May 19, 2022 · 6 comments · May be fixed by #2437
Assignees

Comments

@giulianob
Copy link

Creating a field called "true" then using it in a $select=true throws an error.

Assemblies affected

OData .Net lib 7.10

Reproduce steps

Create a model with an entity property called "true" then try to use it in a $select

Expected result

The $select works and does not throw an error.

Actual result

OData parses the "true" as a boolean and fails because it is not an identifier.

ODataException : An identifier was expected at position ..
Stack:
   at Microsoft.OData.UriParser.ExpressionToken.GetIdentifier()
   at Microsoft.OData.UriParser.SelectExpandTermParser.ParseSegment(PathSegmentToken previousSegment, Boolean allowRef)
   at Microsoft.OData.UriParser.SelectExpandTermParser.ParseTerm(Boolean allowRef)
   at Microsoft.OData.UriParser.SelectExpandParser.ParseSingleSelectTerm()
   at Microsoft.OData.UriParser.SelectExpandParser.ParseCommaSeparatedSelectList(Func`2 ctor, Func`1 termParsingFunc)
   at Microsoft.OData.UriParser.SelectExpandSyntacticParser.Parse(String selectClause, String expandClause, IEdmStructuredType parentStructuredType, ODataUriParserConfiguration configuration, ExpandToken& expandTree, SelectToken& selectTree)
   at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseSelectAndExpandImplementation(String select, String expand, ODataUriParserConfiguration configuration, ODataPathInfo odataPathInfo)
   at Microsoft.OData.UriParser.ODataQueryOptionParser.ParseSelectAndExpand()
@habbes
Copy link
Contributor

habbes commented May 24, 2022

Hi @giulianob true is a treated as a boolean literal. Is it possible to give the property a different name?

@giulianob
Copy link
Author

@habbes We have models that are created by customers and actually ran into a customer using the name "true". This isn't something we can change.

@habbes
Copy link
Contributor

habbes commented May 27, 2022

@giulianob thanks for the additional context. We're looking into this. It should be possible to disambiguate the boolean literal and an identifier called true in some context, like the $select.

@giulianob
Copy link
Author

@habbes We found another case where a customer named a field INF which then makes filters such as INF eq 'y' fail due to INF being a reserved keyword. Is there any workarounds besides renaming the field? Perhaps a way to disambiguate fields from keywords?

@habbes
Copy link
Contributor

habbes commented Jan 31, 2024

@giulianob let's see whether this PR: #2437 addresses that issue as well.

@giulianob
Copy link
Author

@giulianob let's see whether this PR: #2437 addresses that issue as well.

Ok thank you. It looks like the PR was in good shape with minor fixes but hasn't received any updates since 2022. Is it possible to try and get it merged? Thanks!

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

Successfully merging a pull request may close this issue.

3 participants