-
-
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
Updating the path 'x' would create a conflict at 'x' #10646
Comments
I have the feeling that somehow an already converted object id, is converted again to an object id, and this somehow results into loosing the value of the id. Is it possible that there is a check missing if the "id" is already a typeof Types.ObjectId? |
Please include your connection code. |
Likely a duplicate of #10624, upgrade to v6.0.4 and it should go away. If not, let me know, but set |
Sounds very similar, thanks for the hint. I will test it tomorrow and let you know! Thanks! |
I just tested it, it works now! Thanks! But one final question, the model has defaults of "undefined" to ensure that there is no array created. We have this in several places, e.g.
would it be better to just use "setDefaultsOnInsert: false" instead..? the most common use case for default values on our side, is that we set them to undefined that mongoose does no special magic on it. Or is there even an option that there is only a default created if default value is explciity set to an value and disbale the "auto create array" behaviour? Thanks again! |
I'll take a look re: the |
@simllll I took a closer look and can confirm that Mongoose does not add undefined defaults to 'use strict';
const mongoose = require('mongoose');
mongoose.set('debug', true);
run().catch(err => console.log(err));
async function run() {
console.log(`Mongoose version: ${mongoose.version}`);
await mongoose.connect('mongodb://localhost:27017/test');
await mongoose.connection.dropDatabase();
const schema = new mongoose.Schema({
name: String,
tags: { type: [String], default: undefined }
});
const Test = mongoose.model('Test', schema);
await Test.updateOne({}, { name: 'test' }, { upsert: true });
console.log('Done');
} Outputs:
So you don't need to disable |
Interesting, is this since the last update or should it be like this already in earlier versions? The thing is I got this problems with a model that only had default undefined definitions. |
We made some fixes related to |
I'm running into this one since I upgraded to 6.x (6.0.11) today - this one seems to have show stopper quality :/ |
Backporting to 6.0.3 seems to resolve the issue for me. |
@hardcodet can you please open a new issue and follow the issue template? |
this seems to have popped back up in v6.3.X, had to downgrade to 6.1.10 to prevent the error |
Ran into this problem on v6.3.6 as part of upgrading from v5; as also noted by @chemdrew, downgrading to v6.1.10 fixes the issue. |
This problem occurs when use it should be something like this: |
Do you want to request a feature or report a bug?
bug
What is the current behavior?
mongoose throws an error when executing following query, when executed with
throws
but calling it with the native collection, it works:
=> no error at all.
it seems mongoose does some "bad" magic with the query ;).
Works with mongosoe 5.x, but not with mongoose 6.x
What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version.
mongoose 6.0.3
node v16.7.0
mongodb 4.4.1
The text was updated successfully, but these errors were encountered: