Skip to content
This repository
Browse code

smartos-live#108 fix failed match on quick lookup if property type is…

… not string (Thanks MerlinDMC)
  • Loading branch information...
commit ffae0240e84f143d4a756cdbcd947f0824b1bb5a 1 parent f3bfdb3
joshwilsdon joshwilsdon authored

Showing 1 changed file with 7 additions and 3 deletions. Show diff stats Hide diff stats

  1. +7 3 src/vm/node_modules/VM.js
10 src/vm/node_modules/VM.js
@@ -2190,6 +2190,7 @@ exports.lookup = function (search, options, callback) {
2190 2190 var full_results = [];
2191 2191 var match;
2192 2192 var regex;
  2193 + var source;
2193 2194 var target;
2194 2195 var u;
2195 2196 var z;
@@ -2203,14 +2204,18 @@ exports.lookup = function (search, options, callback) {
2203 2204 match = true;
2204 2205 for (key in search) {
2205 2206 regex = false;
  2207 + // force field type to string so that earlier transformed
  2208 + // number fields get back their match method and the
  2209 + // strict not-equal operator will work on number lookups
  2210 + source = '' + z[key];
2206 2211 target = search[key];
2207 2212 if (target[0] === '~') {
2208 2213 target = new RegExp(target.substr(1), 'i');
2209 2214 regex = true;
2210 2215 }
2211   - if (regex && !z[key].match(target)) {
  2216 + if (regex && !source.match(target)) {
2212 2217 match = false;
2213   - } else if (!regex && (z[key] !== search[key])) {
  2218 + } else if (!regex && (source !== search[key])) {
2214 2219 match = false;
2215 2220 }
2216 2221 }
@@ -3535,7 +3540,6 @@ function validRecordSize(candidate)
3535 3540 // update is assumed.
3536 3541 function checkPayloadProperties(payload, vmobj, callback)
3537 3542 {
3538   - var allowed = {};
3539 3543 var array_fields = [
3540 3544 'add_nics', 'update_nics', 'remove_nics',
3541 3545 'add_disks', 'update_disks', 'remove_disks',

0 comments on commit ffae024

Please sign in to comment.
Something went wrong with that request. Please try again.