the following code should fail on the 2nd time doAssert ai is reached because insert fails (we're inserting with same _id):
import std/[
oids,
asyncdispatch,
]
import nimongo/bson
import nimongo/mongo
proc test_sync2=
var m = newMongo()
doAssert m.connect()
let mc = m["tmp"]["tnimongo"]
for i in 0..<2:
let doc = %*{
"name": "bob2",
"_id": 123,
}
let ai = mc.insert(doc)
echo ai
doAssert ai
test_sync2()
here's the equivalent D code, which correctly throws:
the following code should fail on the 2nd time
doAssert ai
is reached because insert fails (we're inserting with same_id
):here's the equivalent D code, which correctly throws:
likewise with python, which also throws
note
echo ai
prints this: theok: true
should beok: false
, and it should fail