Skip to content
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

Key Names with Periods #13530

Closed
vkarpov15 opened this issue Jun 19, 2023 Discussed in #13528 · 0 comments · Fixed by #13536
Closed

Key Names with Periods #13530

vkarpov15 opened this issue Jun 19, 2023 Discussed in #13528 · 0 comments · Fixed by #13536
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Milestone

Comments

@vkarpov15
Copy link
Collaborator

Discussed in #13528

Originally posted by ccravens June 19, 2023
I know it's not supported to have key names with periods in them (I'm sure that's a whole other discussion). But what I'm trying to do is understand why this schema definition results in this:

/*** Document save ******/
        const testModel = await new TestModel({
          metadata: {
            labels: { 'my.label.com': 'true' },
          },
        }).save();

This schema results in this:

const TestModelSchema = new mongoose.Schema({
  metadata: new Schema(
    {
      labels: Schema.Types.Mixed,
    },
    { _id: false }
  ),
});
> db.tests.find()
[
  {
    _id: ObjectId("6490a03b52d559b83ceb3ce2"),
    metadata: { labels: { 'my.label.com': 'true' } },
    __v: 0
  }
]
]

Notice the dots in the key name my.label.com

But schema results in this:

const TestModelSchema = new mongoose.Schema({
  metadata: {
      labels: Schema.Types.Mixed,
    },
});
> db.tests.find()
[
  {
    _id: ObjectId("6490a12452f4cca566b68d6d"),
    metadata: {
      labels: { my: { label: { com: 'true' } } }
    },
    __v: 0
  }
]
```</div>
@vkarpov15 vkarpov15 added this to the 7.3.2 milestone Jun 19, 2023
@vkarpov15 vkarpov15 added the has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue label Jun 19, 2023
@vkarpov15 vkarpov15 added confirmed-bug We've confirmed this is a bug in Mongoose and will fix it. and removed has repro script There is a repro script, the Mongoose devs need to confirm that it reproduces the issue labels Jun 21, 2023
@vkarpov15 vkarpov15 modified the milestones: 7.3.2, 7.4.0 Jun 21, 2023
vkarpov15 added a commit that referenced this issue Jun 24, 2023
fix(document): allow setting keys with dots in mixed paths underneath nested paths
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug We've confirmed this is a bug in Mongoose and will fix it.
Projects
None yet
1 participant