-
-
Notifications
You must be signed in to change notification settings - Fork 962
Description
Feature description
Hello,
SimpleDataBinder uses this regex to parse the indexer and it's value from a value it wants to map:
static final INDEXED_PROPERTY_REGEX = /(.*)\[\s*([^\s]*)\s*\]\s*$/
But this regex will always choose the last indexer when there are multiple present. Example:
propName = 'columns[0]['data']'
will be matched as
indexedPropertyName = 'columns[0]'
index = 'data'
I'd argue that this is wrong. A groovy property is not allowed to be named columns[0]
anyways (right?) so matching that makes no sense. It should instead consider the first indexer as the indexer that matters. It should be:
indexedPropertyName = 'columns'
index = '0'
It would be easy to change the regex to pick the first indexer instead like so:
^(.*?)\[\s*([^\s]*)\s*\]\s*
but I'm not sure if that would break anything and if that's enough to properly support nested indexers. Is this a feature the SimpleDataBinder should support? Since fields that have [] in their name are probably very unlikely to exist, making this change may not be that breaking in real usage.