-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Embedded Shell
-
None
-
Environment:MongoDB Enterprise v4.4.15 and mongosh v1.1.9.
-
Not Needed
Problem Statement/Rationale
$jsonSchema report error on double data type. It is reported by a customer where provided value 2.0 is not recognized as a double value.
Please be sure to attach relevant logs with any sensitive data redacted.
Steps to Reproduce
use rlr
val = { $jsonSchema: { bsonType: 'object', properties: { shippingServiceId:
Unknown macro: { bsonType}, customerPostalCode: { bsonType: 'string', description: 'must be a string' }, depotId: { bsonType: 'int', description: 'must be an int' }, transitDays: { bsonType: 'int', description: 'must be a int' }, cost: { bsonType: 'double', description: 'cost for shipping service' } } } }
db.createCollection( 'ShippingServiceTransitTimeCost', { validator: val })
Insert the following failed:
db.ShippingServiceTransitTimeCost.insert({ shippingServiceId: 1, customerPostalCode: "12345", transitDays: 2, depotId: 13, cost: 2.0 })
Change `cost: 2.0` to `cost: 2.1` worked.
db.ShippingServiceTransitTimeCost.insert({ shippingServiceId: 1, customerPostalCode: "12345", transitDays: 2, depotId: 13, cost: 2.1 })
The following also worked:
{{db.ShippingServiceTransitTimeCost.insert({ shippingServiceId: 1, customerPostalCode: "12345", transitDays: 2, depotId: 13, cost: Double('2.0') })}}
{{{}}Expected Results
acknowledged: true,
{{ insertedIds: { '0': ObjectId("62c6febcff2ba21ad88c843e") }}}
{{}}}
{{Result: BulkWriteResult {}}Actual Results
result: {
ok: 1,
writeErrors: [
WriteError {
err: {
index: 0,
code: 121,
errmsg: 'Document failed validation',
errInfo: undefined,
op: {
shippingServiceId: 1,
customerPostalCode: '12345',
transitDays: 2,
depotId: 13,
cost: 2,
_id: ObjectId("62c6fea3ff2ba21ad88c843d")
{{ }}}
{{ }}}
{{ }}}
],
writeConcernErrors: [],
insertedIds: [ { index: 0, _id: ObjectId("62c6fea3ff2ba21ad88c843d") } ],
nInserted: 0,
nUpserted: 0,
nMatched: 0,
nModified: 0,
nRemoved: 0,
upserted: [],
{{ opTime: { ts: Timestamp({ t: 1657208473, i: 1 }), t: Long("11") }}}
{{ }}}
h3. Additional Notes
Any additional information that may be useful to include.