Skip to content

mongo doesn't like dotted keys#425

Merged
tjmehta merged 2 commits intomasterfrom
only-cache-inspect-state
Dec 11, 2014
Merged

mongo doesn't like dotted keys#425
tjmehta merged 2 commits intomasterfrom
only-cache-inspect-state

Conversation

@tjmehta
Copy link
Copy Markdown
Contributor

@tjmehta tjmehta commented Dec 11, 2014

No description provided.

@podviaznikov
Copy link
Copy Markdown
Member

how did you find that there is a problem with the dotted keys?

@bkendall
Copy link
Copy Markdown
Contributor

are you sure it was the dots? I thought it might have been the forward slashes...

@tjmehta
Copy link
Copy Markdown
Contributor Author

tjmehta commented Dec 11, 2014

exception: The dotted field '/etc/nginx/conf.d' in 'container.inspect.Config.Volumes./etc/nginx/conf.d' is not valid for storage.

@tjmehta
Copy link
Copy Markdown
Contributor Author

tjmehta commented Dec 11, 2014

"dotted-field"

@tjmehta
Copy link
Copy Markdown
Contributor Author

tjmehta commented Dec 11, 2014

We're getting 1 test failure currently on master - which is the one you see. it passes locally was going to debug it in the morning.

@tjmehta
Copy link
Copy Markdown
Contributor Author

tjmehta commented Dec 11, 2014

btw i did a unit test on the dotted key removal here are the results
BEFORE

{
  foo: {
    bar: {
      baz: {
        "wut.hey": 10,
        "w.hey": 10,
        yolo: 10
      }
    }
  },
  baz: {
    "wut.hey": 10,
    "w.hey": 10,
    yolo: 10
  },
  "wut.hey": 10,
  yolo: 10,
  "but.hey": 10
}

UNIT

function removeDottedKeys (obj) {
    if (typeof obj === 'object') {
        Object.keys(obj).forEach(function (key) {
            if (~key.indexOf('.')) {
                delete obj[key];
            }
            removeDottedKeys(obj[key]);
        });
    }
}

var x = {
  foo: {
    bar: {
      baz: {
        "wut.hey": 10,
        "w.hey": 10,
        yolo: 10
      }
    }
  },
  baz: {
    "wut.hey": 10,
    "w.hey": 10,
    yolo: 10
  },
  "wut.hey": 10,
  yolo: 10,
  "but.hey": 10
};
removeDottedKeys(x);
console.log(JSON.stringify(x, null, '\t'));

AFTER

{
    "foo": {
        "bar": {
            "baz": {
                "yolo": 10
            }
        }
    },
    "baz": {
        "yolo": 10
    },
    "yolo": 10
}

@bkendall
Copy link
Copy Markdown
Contributor

❤️ for tests

@tjmehta
Copy link
Copy Markdown
Contributor Author

tjmehta commented Dec 11, 2014

Verified on staging - issue repros when using a Volume with a "." in the path - I have fix on staging and problem does not repro anymore

@tjmehta
Copy link
Copy Markdown
Contributor Author

tjmehta commented Dec 11, 2014

so the problem is resolved.

@tjmehta
Copy link
Copy Markdown
Contributor Author

tjmehta commented Dec 11, 2014

thanks for the review!

tjmehta added a commit that referenced this pull request Dec 11, 2014
@tjmehta tjmehta merged commit 0733cd1 into master Dec 11, 2014
@tjmehta tjmehta deleted the only-cache-inspect-state branch December 11, 2014 06:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants