Skip to content

Allow populating paths with spaces #13985

Description

@vkarpov15

Prerequisites

  • I have written a descriptive issue title
  • I have searched existing issues to ensure the issue has not already been raised

Issue

The following test fails, there's no way to populate the 'original author' path that I can see:

    it('allows populating path with space in name (gh-13951)', async function() {
      const BlogPost = db.model('BlogPost', new Schema({
        title: String,
        'original author': { type: ObjectId, ref: 'User' },
        author: { type: ObjectId, ref: 'User' }
      }));
      const User = db.model('User', new Schema({ name: String }));

      const fans = await User.create([{ name: 'Fan 1' }]);
      const posts = [
        { title: 'Test 1', author: fans[0]._id, 'original author': fans[0]._id }
      ];
      await BlogPost.create(posts);
      const blogPost = await BlogPost.
        findOne({ title: 'Test 1' }).
        populate({ path: 'original author' });

      assert.equal(blogPost['original author'].name, 'Fan 1');
      assert.equal(blogPost.title, 'Test 1');
    });

Worth finding a way to support this behavior without breaking existing logic that relies on whitespace to separate multiple paths.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    backwards-breakingdiscussionIf you have any thoughts or comments on this issue, please share them!

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions