Open lisovyk opened 2 years ago
Can you give an example how I can setup such a validated collection, in order to reproduce the problem?
Sure, will do in couple of hours!
On Sun, May 29, 2022, 15:58 Jeroen Ooms @.***> wrote:
Can you give an example how I can setup such a validated collection, in order to reproduce the problem?
— Reply to this email directly, view it on GitHub https://github.com/jeroen/mongolite/issues/241#issuecomment-1140444179, or unsubscribe https://github.com/notifications/unsubscribe-auth/AF6FCEASW4DSZ446WVV7HA3VMNSXFANCNFSM5XEULFNA . You are receiving this because you authored the thread.Message ID: @.***>
Create a database table with a validator, taken example from here
db.createCollection( "contacts", {
validator: { $jsonSchema: {
bsonType: "object",
required: [ "phone" ],
properties: {
phone: {
bsonType: "string",
description: "must be a string and is required"
},
email: {
bsonType : "string",
pattern : "@mongodb\.com$",
description: "must be a string and match the regular expression pattern"
},
status: {
enum: [ "Unknown", "Incomplete" ],
description: "can only be one of the enum values"
}
}
} }
} )
Try to write with wrong column type from R, e.g.
library(mongolite)
db_connection <- mongo(...) # not sure about that part on localhost, sorry
db_connection$insert('{ "name": "Amanda", "status": "Updated"}') #gives validation error
Please, add context to the error message when validation is failing upon insert.
As of mongolite version
2.3.1
it gives a general validation error:While in mongo console I can get a right away answer into what's causing validation error:
Alternatively, please give me a hint on how to find that error json in mongolite, setting log_level didn't do it and I digged into source code to no avail :(