            .replace('{limit}', limit)
            .replace('{offset}', offset);
            
-  print(NOTICE, 'sql = ',  sql);
+  if(debug) { print(NOTICE, 'sql = ', sql); }
 
   recs = executeSql(sql);
 

  return JSON.stringify(recs);

$$ language plv8;

select private.fetch('XM.Contact',E'{"parameters":{ 
                                       "firstName": "Jake", 
                                       "lastName": "F"
                                     }, 
                                     "conditions":"firstName = {firstName} OR lastName STARTS_WITH {lastName}", 
                                     "orderBy":"lastName"}', 3);
                                 .replace('CONTAINS','~')
                                 .replace('MATCHES','~')
                                 .replace('ANY', '<@ array'));

      quoteIfString = function(arg) { 
        if(typeof arg === 'string') { 
          return "'" + arg + "'"; 
        }

        return arg;
      }
      
      if(parameters) {
        if(ret.indexOf('%@') > 0) {  /* replace wild card tokens */
          for(var prop in parameters) {
            var n = ret.indexOf('%@'),
                val =  quoteIfString(parameters[prop]);

            ret = ret.slice(0, n) + val + ret.slice(n + 2);
          }
        } else {  /* replace parameterized tokens */
          for(var prop in parameters) {
            var param = '{' + decamelize(prop) + '}',
                val = quoteIfString(parameters[prop]);
            
            ret = ret.replace(param, val);
          }
        }
      }
    }
