agrestio / agrest

Server-side Java REST Framework for easy access to data graphs from various backends
https://agrest.io
Apache License 2.0
80 stars 34 forks source link

Exp: scalar encoding is incompatible with the parser rules #650

Open andrus opened 11 months ago

andrus commented 11 months ago

ExpScalar.toString doesn't follow the rules of the parser. It effectively calls value.toString(). The only special rule is that it encloses it in single quotes if it is a char sequence. We need the encoding to be complimentary to the literals grammar used by the parser:

Long l = 3147483647L; // encode as 3147483647L, not 314748364
BigDecimal d = new BigDecimal("2.1000001B"); // encode as 2.1000001B, not 2.1000001
// same for floats...

String s1 = "a'b"; // encode as "a'b", not 'a'b'
String s1 = "a\"'b"; // encode as 'a"\'b, not 'a"'b'