关于OData不同版本中$filter数字字面量后缀有效性的确认及版本变更官方依据咨询
结论确认
Your observations are spot-on—let's break this down clearly to confirm your conclusions and tie them to official OData specs:
- OData 2.0 & 3.0: Numeric literal suffixes are supported (and in some scenarios required) to explicitly define the Edm data type of the literal. The type mappings you discovered are 100% accurate:
d→ Edm.Doublef→ Edm.SingleL→ Edm.Int64m/M→ Edm.Decimal- Invalid suffixes (like
a/b) trigger syntax errors, while mismatched suffixes (e.g.,d/fpaired with an Edm.Decimal property) result in type mismatch errors.
- OData 4.0+: Numeric literal suffixes are no longer valid. The system automatically infers the Edm type of the literal based on context (such as the property it's being compared against). Using any suffix in 4.0+ will throw a syntax error.
Official Documentation References
Here's how this aligns with specific sections of the OData specification:
OData 2.0
- URI Conventions > 4.5 Filter System Query Option ($filter): While the documentation links
32dto32in examples,32dis a valid literal in actual requests to explicitly denote an Edm.Double value. - Overview > 6. Primitive Data Types: Defines the suffix rules for numeric literals to distinguish between different Edm numeric types.
OData 3.0
- URL Conventions > 5.1.2 Filter System Query Option ($filter) > 5.1.2.2.6 Arithmetic Operator Examples: Explicitly mentions using the
Msuffix to represent an Edm.Decimal literal (e.g.,Freight gt 100Mfor an Edm.Decimal property).
OData 4.0+ (including 4.01)
- Part 1: Protocol > 11.2.6.1.2 Built-in Query Functions > Arithmetic Functions: No references to numeric literal suffixes exist—all numeric literals have their types inferred from context.
- Part 2: URL Conventions > 5.1.1.9 Arithmetic Functions > 5.1.1.9.3 round Function: Examples only use suffix-free numeric literals (e.g.,
round(Freight) eq 32). - ABNF Construction Rules >
decimalValue =: The defined format for decimal literals does not include any suffixes, confirming that suffixes were removed starting in OData 4.0.
内容的提问来源于stack exchange,提问作者Sandra Rossi
相关产品推荐
相关产品推荐

