@@ -12,6 +12,8 @@ module Puppet::Parser::Functions
12
12
13
13
When there is a duplicate key that is a hash, they are recursively merged.
14
14
When there is a duplicate key that is not a hash, the key in the rightmost hash will "win."
15
+ When there are conficting uses of dashes and underscores in two keys (which mysql would otherwise equate),
16
+ the rightmost style will win.
15
17
16
18
ENDHEREDOC
17
19
@@ -36,17 +38,21 @@ module Puppet::Parser::Functions
36
38
end
37
39
end
38
40
41
+ def has_normalized! ( hash , key )
42
+ return true if hash . has_key? ( key )
43
+ return false unless key . match ( /-|_/ )
44
+ other_key = key . include? ( '-' ) ? key . gsub ( '-' , '_' ) : key . gsub ( '_' , '-' )
45
+ return false unless hash . has_key? ( other_key )
46
+ hash [ key ] = hash . delete ( other_key )
47
+ return true ;
48
+ end
49
+
39
50
def overlay ( hash1 , hash2 )
40
- hash2 . each do |key , value |
41
- if ( value . is_a? ( Hash ) )
42
- if ( ! hash1 . has_key? ( key ) or ! hash1 [ key ] . is_a? ( Hash ) )
43
- hash1 [ key ] = value
44
- else
45
- overlay ( hash1 [ key ] , value )
46
- end
47
- else
48
- hash1 [ key ] = value
49
- end
51
+ hash2 . each do |key , value |
52
+ if ( has_normalized! ( hash1 , key ) and value . is_a? ( Hash ) and hash1 [ key ] . is_a? ( Hash ) )
53
+ overlay ( hash1 [ key ] , value )
54
+ else
55
+ hash1 [ key ] = value
50
56
end
57
+ end
51
58
end
52
-
0 commit comments