-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
different behavior for key starting with dot ('.') #14178
Labels
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
Milestone
Comments
IslandRhythms
added
the
confirmed-bug
We've confirmed this is a bug in Mongoose and will fix it.
label
Dec 14, 2023
var mongoose = require('mongoose')
console.log(mongoose.version)
const Schema = mongoose.Schema
const eventSchema = new Schema({
name: { type: String },
field3: { type: Schema.Types.Mixed },
__stateBeforeSuspension: {
field1: { type: String },
field2: { type: String },
field3: { type: Schema.Types.Mixed },
jsonField: {
name: { type: String },
ex: { type: String }
}
}
})
eventSchema.add({
test: {
val1: { type: String },
val2: { type: String }
}
})
eventSchema.add({
subSchema4: [{ field1: { type: String } }, { field2: { type: String } }]
})
const Event = mongoose.model('Event', eventSchema)
async function run() {
await mongoose.connect('mongodb://localhost:27017/gh14178');
await mongoose.connection.dropDatabase();
let eventObj = new Event({ name: 'event object', __stateBeforeSuspension: { field1: 'test', jsonField: { name: null, ex: 'test' }}, test: { val1: 'hello', val2: 'there' }, subSchema4: [{ field1: 'test' }, { field2: 'test2' }] })
eventObj.save(function (err, eventObj) {
const newO = eventObj.toObject()
newO.__stateBeforeSuspension.field3 = {'.ippo': 5}
eventObj.set(newO)
eventObj.save(function (err, eventObj) {
console.log(eventObj)
})
})
}
run(); |
@vkarpov15 @IslandRhythms, Can you please let us know if there is any tentative time line to release this one. |
vkarpov15
added a commit
that referenced
this issue
Dec 27, 2023
vkarpov15
added a commit
that referenced
this issue
Dec 28, 2023
fix(document): avoid flattening dotted paths in mixed path underneath nested path
@sakethyerra we'll ship 6.12.5 with the fix next week |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Mongoose version
6.12.3
Node.js version
18.12.1
MongoDB server version
4.4
Typescript version (if applicable)
No response
Description
Output with 6.12.3
Output with 5.12.5
Steps to Reproduce
__stateBeforeSuspension.field3 in 5.12.5 : { '.ippo': 5 }
__stateBeforeSuspension.field3 in 6.12.3 : { '': [Object] } ( the [Object] is {'ippo': 5}, key is empty )
Expected Behavior
Expecting 5.12.5 behavior will be supported
The text was updated successfully, but these errors were encountered: