joyent/smartos-live — pull request #108 by MerlinDMC (2012-08-04 19:06:33+00:00)
Title: vmadm lookup does not work for some quick_lookup fields

After applied transformations not all attributes of the zone payload are strings anymore.

If the attribute is no string the .match method for RegEx searches is not available and a strict match against a string in the search object always fails.

To reproduce this behavior just try to match a zoneid field:
`vmadm lookup zoneid=1` or `vmadm lookup zoneid=~1`

The RegEx match will return a TypeError:
```
/usr/vm/node_modules/VM.js:2211
if (regex && !z[key].match(target)) {
^
TypeError: Object 1 has no method 'match'
at exports.lookup (/usr/vm/node_modules/VM.js:2211:42)
at /usr/vm/node_modules/VM.js:1701:9
at _asyncMap (/usr/node/0.8/node_modules/async.js:166:13)
at async.forEachSeries.iterate (/usr/node/0.8/node_modules/async.js:129:25)
at _asyncMap (/usr/node/0.8/node_modules/async.js:163:17)
at async.series.results (/usr/node/0.8/node_modules/async.js:461:34)
at /usr/vm/node_modules/VM.js:1696:17
at async.forEachSeries.iterate (/usr/node/0.8/node_modules/async.js:129:25)
at /usr/vm/node_modules/VM.js:1693:21
at async.forEachSeries.iterate (/usr/node/0.8/node_modules/async.js:121:13)
```

My patch simply forces the quick_lookup fields back to a string before matching.
Properties that are not part of the quick_lookup list seem to match fine.