[SERVER-30742] Fail with a useful error message when given "integer" type keyword for JSON Schema Created: 18/Aug/17 Updated: 30/Oct/23 Resolved: 11/Sep/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | 3.5.13 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Kyle Suarez | Assignee: | Nicholas Zolnierz |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Backwards Compatibility: | Fully Compatible |
| Sprint: | Query 2017-10-02 |
| Participants: |
| Description |
|
JSON Schema Draft 04 accepts "integer" as a primitive JSON type. However, we do not plan to support this in MongoDB's implementation. If we encounter type: "integer", we should fail during parsing with a useful error message. |
| Comments |
| Comment by Ramon Fernandez Marina [ 11/Sep/17 ] |
|
Author: {'username': u'nzolnierzmdb', 'name': u'Nick Zolnierz', 'email': u'nicholas.zolnierz@mongodb.com'}Message: |
| Comment by David Storch [ 23/Aug/17 ] |
|
asya that seems reasonable, but I have two reservations:
kyle.suarez, instead of closing as Won't Fix, we should convert this into a task about error reporting. The error should be along the lines of "type:"integer" is not supported" rather than "unknown type". |
| Comment by Kyle Suarez [ 23/Aug/17 ] |
|
david.storch, given Asya's feedback I think we should just close this as Won't Fix. |
| Comment by Asya Kamsky [ 23/Aug/17 ] |
|
From the product perspective, I would prefer that we don't support the keyword "integer".
|
| Comment by David Storch [ 23/Aug/17 ] |
I was hoping it would be sufficient for a number to match {type: "integer"} if it has an exact representation as a NumberLong. We already have well-tested code which implements this in the match expression parser: So a follow-up question is, would this have to work for decimal128 integers that are too large positive or too large negative to fit inside a 64 bit signed integer? |
| Comment by Kyle Suarez [ 23/Aug/17 ] |
|
asya, after discussing with david.storch, we think we should do this, and that the "integer" type alias should:
It's not fully spec-compliant with JSON Schema, but this is as close as we're going to get given that MongoDB is more than just JSON. What's your take on this? As an aside, the second bullet point may be tricky, especially for extremely large binary64 or decimal128 values, as I'm not sure if we can simply round-trip to an integer supported by C++. |
| Comment by Kyle Suarez [ 18/Aug/17 ] |
|
It's worth noting that more recent versions of the JSON Schema drafts don't include "integer". However, I personally think we should add it, since we advertise that we support Draft 04 and this won't be too difficult to do. |