filtertypesodata

Suffix of $filter numeric literals ("number eq '5m'", "eq '5d'", ...) only valid before OData 4.0?


I see that sometimes it's possible to post a $filter OData 2.0 request with numeric literal values suffixed with one letter, like can be tested here "round(Freight) eq 32l". It also works identically by removing the suffix or using suffixes m, M, L. If using d or f there's a type mismatch error (floating point literal used with an Edm.Decimal property). If using a, b (among others) it indicates a syntax error.

Sometimes, it seems that this suffix is mandatory, and sometimes not.

I have searched in the OData standards a little bit (my findings are described below). I came to the conclusion that in OData 2.0 and 3.0 these suffixes were mandatory, but since OData 4.0 these suffixes are invalid. (edited text, see EDIT 1)

Could you confirm that, and could you share some official OData explanations to explain this big change in OData 4.0?

My findings:

(1) OData 2.0 > URI Conventions, then scroll to 4.5. Filter System Query Option ($filter) (althouth the text "32d" refers to link with "32", but setting manually "32d" in the URL also works):

OData 2.0 > URI Conventions > 4.5. Filter System Query Option ($filter)

(2) OData 2.0 > Overview, then scroll to 6. Primitive Data Types:

OData 2.0 > Overview > 6. Primitive Data Types

(3) OData 3.0 > URL Conventions, then scroll to 5.1.2. Filter System Query Option ($filter) and 5.1.2.2.6. Arithmetic Operator Examples, there are mentions to "M" numeric literals (Edm.Decimal):

OData 3.0 > URL Conventions > 5.1.2. Filter System Query Option ($filter) > 5.1.2.2.6. Arithmetic Operator Examples

(4) OData 4.01 > Part 1: Protocol > 11.2.6.1.2. Built-in Query Functions, then scroll to Arithmetic Functions, there's no more mention of "32d":

OData 4.01 > Part 1: Protocol > 11.2.6.1.2. Built-in Query Functions, then scroll to Arithmetic Functions

(5) OData 4.01 > Part 2: URL Conventions > 5.1.1.9. Arithmetic Functions > 5.1.1.9.3 round:

OData 4.01 > Part 2: URL Conventions > 5.1.1.9. Arithmetic Functions > 5.1.1.9.3 round

(6) OData ABNF Construction Rules Version 4.01, then scroll to "decimalValue ="

OData ABNF Construction Rules Version 4.01 > rules for numeric literals

EDIT 1 (July 9th, 2024): looking at OData 3.0 again, I don't see the same as in 2022, so the change happened in OData 4.0.


Solution

  • The suffixes d, f, and m are only allowed (and required by some implementations) in OData V2.

    Numeric literals in OData V4 don't need or allow these suffixes.