lib/connection/statement.js
function buildBindsMap(bindsArray)
{
  var bindsMap = {};
  var isArrayBinding = bindsArray.length >0 && Util.isArray(bindsArray[0]);
  var singleArray = isArrayBinding ? bindsArray[0] : bindsArray;

  for (var index = 0, length = singleArray.length; index < length; index++)
  {
    var value = singleArray[index];

    // pick the appropriate logical data type based on the bind value
    var type;
    if (Util.isBoolean(value))
    {
      type = 'BOOLEAN';
    }
    else if (Util.isObject(value) || Util.isArray(value))
    {
      type = 'VARIANT';
    }
    else if (Util.isNumber(value))
    {
      type = 'REAL';
    }
    else 
    {
      type = 'TEXT';
    }

    // convert non-null values to a string if necessary; we don't convert null
    // because the client might want to run something like
    //   sql text = update t set name = :1 where id = 1;, binds = [null]
    // and converting null to a string would result in us executing
    //   sql text = update t set name = 'null' where id = 1;
    // instead of
    //   sql text = update t set name = null where id = 1;
    if (!isArrayBinding)
    {
      if (value !== null && !Util.isString(value))
      {
        value = JSON.stringify(value);
      }
    }
    else
    {
      value = [];
      for (var rowIndex = 0; rowIndex < bindsArray.length; rowIndex++)
      {
        var value0 = bindsArray[rowIndex][index];
        if (value0 !== null && !Util.isString(value0))
        {
          value0 = JSON.stringify(value0);
        }
        value.push(value0);
      }
    }

    // add an entry for the bind variable to the map
    bindsMap[index + 1] =
    {
      type  : type,
      value : value
    };
  }

  return bindsMap;
}
function buildBindsMap(bindsArray)
{
  var bindsMap = {};
  var isArrayBinding = bindsArray.length >0 && Util.isArray(bindsArray[0]);
  var singleArray = isArrayBinding ? bindsArray[0] : bindsArray;

  for (var index = 0, length = singleArray.length; index < length; index++)
  {
    var value = singleArray[index];

    // pick the appropriate logical data type based on the bind value
    var type;
    if (Util.isBoolean(value))
    {
      type = 'BOOLEAN';
    }
    else if (Util.isObject(value) || Util.isArray(value))
    {
      type = 'VARIANT';
    }
    else if (Util.isNumber(value))
    {
      type = 'REAL';
    }
    else 
    {
      type = 'TEXT';
    }

    // convert non-null values to a string if necessary; we don't convert null
    // because the client might want to run something like
    //   sql text = update t set name = :1 where id = 1;, binds = [null]
    // and converting null to a string would result in us executing
    //   sql text = update t set name = 'null' where id = 1;
    // instead of
    //   sql text = update t set name = null where id = 1;
    if (!isArrayBinding)
    {
      if (value !== null && !Util.isString(value))
      {
        value = JSON.stringify(value);
      }
    }
    else
    {
      value = [];
      for (var rowIndex = 0; rowIndex < bindsArray.length; rowIndex++)
      {
        var value0 = bindsArray[rowIndex][index];
        if (value0 !== null && !Util.isString(value0))
        {
          value0 = JSON.stringify(value0);
        }
        value.push(value0);
      }
    }

    // add an entry for the bind variable to the map
    bindsMap[index + 1] =
    {
      type  : type,
      value : value
    };
  }

  return bindsMap;
}
function buildBindsMap ( bindsArray ) { var bindsMap = { } ; var isArrayBinding = bindsArray . length > 0 && Util . isArray ( bindsArray [ 0 ] ) ; var singleArray = isArrayBinding ? bindsArray [ 0 ] : bindsArray ; for ( var index = 0 , length = singleArray . length ; index < length ; index ++ ) { var value = singleArray [ index ] ; // pick the appropriate logical data type based on the bind value var type ; if ( Util . isBoolean ( value ) ) { type = 'BOOLEAN' ; } else if ( Util . isObject ( value ) || Util . isArray ( value ) ) { type = 'VARIANT' ; } else if ( Util . isNumber ( value ) ) { type = 'REAL' ; } else { type = 'TEXT' ; } // convert non-null values to a string if necessary; we don't convert null // because the client might want to run something like //   sql text = update t set name = :1 where id = 1;, binds = [null] // and converting null to a string would result in us executing //   sql text = update t set name = 'null' where id = 1; // instead of //   sql text = update t set name = null where id = 1; if ( ! isArrayBinding ) { if ( value !== null && ! Util . isString ( value ) ) { value = JSON . stringify ( value ) ; } } else { value = [ ] ; for ( var rowIndex = 0 ; rowIndex < bindsArray . length ; rowIndex ++ ) { var value0 = bindsArray [ rowIndex ] [ index ] ; if ( value0 !== null && ! Util . isString ( value0 ) ) { value0 = JSON . stringify ( value0 ) ; } value . push ( value0 ) ; } } // add an entry for the bind variable to the map bindsMap [ index + 1 ] = { type : type , value : value } ; } return bindsMap ; }
Converts a bind variables array to a map that can be included in the
POST-body when issuing a pre-exec statement request.

@param bindsArray

@returns {Object}
Converts a bind variables array to a map that can be included in the POST - body when issuing a pre - exec statement request .