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

Revert "turn keys to lowercase to enable cross overrides" #2

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/path/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ impl Expression {
match *self {
Self::Identifier(ref id) => match root.kind {
ValueKind::Table(ref mut map) => Some(
map.entry(id.to_lowercase())
map.entry(id.clone())
.or_insert_with(|| Value::new(None, ValueKind::Nil)),
),

Expand All @@ -131,15 +131,15 @@ impl Expression {
Some(value) => {
if let ValueKind::Table(ref mut map) = value.kind {
Some(
map.entry(key.to_lowercase())
map.entry(key.clone())
.or_insert_with(|| Value::new(None, ValueKind::Nil)),
)
} else {
*value = Map::<String, Value>::new().into();

if let ValueKind::Table(ref mut map) = value.kind {
Some(
map.entry(key.to_lowercase())
map.entry(key.clone())
.or_insert_with(|| Value::new(None, ValueKind::Nil)),
)
} else {
Expand Down Expand Up @@ -193,25 +193,25 @@ impl Expression {
ValueKind::Table(ref incoming_map) => {
// Pull out another table
let target = if let ValueKind::Table(ref mut map) = root.kind {
map.entry(id.to_lowercase())
map.entry(id.clone())
.or_insert_with(|| Map::<String, Value>::new().into())
} else {
unreachable!();
};

// Continue the deep merge
for (key, val) in incoming_map {
Self::Identifier(key.to_lowercase()).set(target, val.clone());
Self::Identifier(key.clone()).set(target, val.clone());
}
}

_ => {
if let ValueKind::Table(ref mut map) = root.kind {
// Just do a simple set
if let Some(existing) = map.get_mut(&id.to_lowercase()) {
if let Some(existing) = map.get_mut(id) {
*existing = value;
} else {
map.insert(id.to_lowercase(), value);
map.insert(id.clone(), value);
}
}
}
Expand All @@ -224,7 +224,7 @@ impl Expression {
// Didn't find a table. Oh well. Make a table and do this anyway
*parent = Map::<String, Value>::new().into();
}
Self::Identifier(key.to_lowercase()).set(parent, value);
Self::Identifier(key.clone()).set(parent, value);
}
}

Expand Down
Loading