Repository: chimpler/pyhocon

Issue:
${?foo} unsets previous value if new is undefined
pyhocon==0.3.2

Apparently `${?VAR_NAME}` no longer complains about undefined variables but is seems to be unsetting the key. My expectation is that `${?foo}` would leave the key referencing the last value unless it had something to replace it with.

```
...
  File "/Users/bkuberek/Development/people-service/.venv/lib/python2.7/site-packages/pyhocon/__init__.py", line 203, in parse
    ConfigParser._resolve_substitutions(config, substitutions)
  File "/Users/bkuberek/Development/people-service/.venv/lib/python2.7/site-packages/pyhocon/__init__.py", line 246, in _resolve_substitutions
    is_optional_resolved, resolved_value = ConfigParser._resolve_variable(config, substitution)
  File "/Users/bkuberek/Development/people-service/.venv/lib/python2.7/site-packages/pyhocon/__init__.py", line 228, in _resolve_variable
    col=col(substitution.loc, substitution.instring)))
pyhocon.exceptions.ConfigSubstitutionException: Cannot resolve variable ${database.name} (line: 20, col: 102)
```

Here is my configuration:
```
{
  database {
    host = "localhost"
    port = "5432"
    user = "people"
    name = "peopledb"
    pass = "dev"
    url = "postgresql://"${database.user}":"${database.pass}"@"${database.host}":"${database.port}"/"${database.name}

    # Override from environment variables if they exist
    host = ${?DB_HOST}
    port = ${?DB_PORT}
    user = ${?DB_USER}
    name = ${?DB_NAME}
    pass = ${?DB_PASS}
  }
}
```


Discussion:

Patch:
diff --git a/pyhocon/config_tree.py b/pyhocon/config_tree.py
index 60b2d88..d045c7b 100644
--- a/pyhocon/config_tree.py
+++ b/pyhocon/config_tree.py
@@ -70,6 +70,9 @@ class ConfigTree(OrderedDict):
                             type=l.__class__.__name__)
                     )
             else:
+                # if there was an override keep overide value
+                if isinstance(value, ConfigValues):
+                    value.overriden_value = self.get(key_elt, None)
                 super(ConfigTree, self).__setitem__(key_elt, value)
         else:
             next_config_tree = super(ConfigTree, self).get(key_elt)


Test patch:
diff --git a/tests/test_config_parser.py b/tests/test_config_parser.py
index b343d35..c0dbb15 100644
--- a/tests/test_config_parser.py
+++ b/tests/test_config_parser.py
@@ -797,7 +797,21 @@ class TestConfigParser(object):
         assert config['database.user'] == 'test_user'
         assert config['database.pass'] == 'test_pass'
 
-    def test_substitution_override(self):
+    def test_substitution_flat_override(self):
+        config = ConfigFactory.parse_string(
+            """
+            database {
+                name = peopledb
+                pass = peoplepass
+                name = ${?NOT_EXISTS}
+                pass = ${?NOT_EXISTS}
+            }
+            """)
+
+        assert config['database.name'] == 'peopledb'
+        assert config['database.pass'] == 'peoplepass'
+
+    def test_substitution_nested_override(self):
         config = ConfigFactory.parse_string(
             """
             database {