Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Numbers #5

Closed
jaalfaro opened this issue Apr 24, 2013 · 4 comments · Fixed by #11 · May be fixed by #7
Closed

Numbers #5

jaalfaro opened this issue Apr 24, 2013 · 4 comments · Fixed by #11 · May be fixed by #7

Comments

@jaalfaro
Copy link

There seem to be some issues in your parsing of numbers. It appears your logic to determine types fails particularly on bytes. You may want to take a look at the spec for abstract types at http://www.odata.org/documentation/overview/#AbstractTypeSystem. You will probably have to reorder your logic for detection.

For example. $filter=Field1 eq 9999 captures 999 as a byte when its not. The format for bytes is 2 characters [A-Fa-f0-9]+ so this results in a failure for the call.

@mangvlad
Copy link

mangvlad commented Feb 4, 2014

Not sure if this is related but I have this query: '$filter=test eq 12345'

And this is what I am getting:

{
"name": "SyntaxError",
"expected": [
"" "",
""&""
],
"found": "2",
"message": "Expected " " or "&" but "2" found.",
"offset": 17,
"line": 1,
"column": 18
}
Am I doing something wrong?

Thanks.

@jwanga
Copy link

jwanga commented May 15, 2014

Im experiencing the same issue.

odata.parse('$filter=Temperature gt 50');

yields the expression object:

{
'$filter': {
type: 'gt',
left: { type: 'property', name: 'Temperature' },
right: { type: 'literal', value: 5 }
}
}

@jadrake75
Copy link

Any word on a resolution for this? I just found this library to hook into my code to help translate $filter strings to MySQL where clauses and this is a show-stopper for me.

To see the problem change the test:

it('should parse numbers okay', function(){
var ast = parser.parse('$filter=status eq 35');
assert.equal(ast.$filter.right.value, 35); // this will fail is it will be 3
});

@prantlf
Copy link
Contributor

prantlf commented Dec 27, 2014

A "quick and dirty" workaround could be commenting out lines byte /' and sbyte / from the primitiveLiteral specification in src/odata.pegjs and running npm prepublish to get the lib/odata-parser.js updated.

There seems to be a problem with parsing integers and the order of processing of integers and bytes.

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

Successfully merging a pull request may close this issue.

5 participants