Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

helenus

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

helenus - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

10

History.md

@@ -122,2 +122,10 @@

* Fixed issue in tombstone column deserialization [ @devdazed #33 ]
* Added support for Int32Type and DecimalType [ @ctavan #23 ]
* Added support for Int32Type and DecimalType [ @ctavan #23 ]
0.5.0 / 2012-04-20
==================
* Use debian packages for Travis-CI [ @ctavan #40 ]
* Stop Cassandra after tests in Travis-CI [ @ctavan #41 ]
* Add support for ColumnFamily.truncate [ @devdazed #28 ]
* Add better CQL escaping and parameterization [ @devdazed #36, #39 ]

@@ -299,3 +299,12 @@ var util = require('util'),

/**
* Truncates a ColumnFamily
* @param {Function} callback The callback to invoke once the ColumnFamily has been truncated
*/
ColumnFamily.prototype.truncate = function(callback){
this.connection.execute('truncate', this.name, callback);
};
/**
* Gets rows by their indexed fields

@@ -302,0 +311,0 @@ * @param {Object} query Options for the rows part of the get

@@ -57,14 +57,75 @@

/**
* Escapes a string as required by CQL
* Formats CQL properly, paradigm borrowed from node-mysql:
* https://github.com/felixge/node-mysql/blob/master/lib/client.js#L145-199
*
* @param {String} str
* @private
* @memberOf Connection
* @returns {String} The formatted CQL statement
*/
function formatCQL(cql, params){
//replace a %% with a % to maintain backward compatibility with util.format
cql = cql.replace(/%%/, '%');
//remove existing quotes around parameters in case the user has already wrapped them
cql = cql.replace(/'(\?|%[sjd])'/g, '$1');
//escape the params and format the CQL string
cql = cql.replace(/\?|%[sjd]/g, function() {
if (params.length === 0) {
throw createError(new Error('Too Few Parameters Given'));
}
return escapeCQL(params.shift());
});
if (params.length) {
throw createError(new Error('Too Many Parameters Given'));
}
return cql;
}
/**
* Escapes CQL, adapted from node-mysql
* @param {String} val The value to be escaped
* @private
* @memberOf Connection
* @returns {String} The sanitized string
*/
function cqlEscape(str){
if(str instanceof Buffer){
return str.toString('hex');
} else {
return str.toString().replace(/\'/img, '\'\'');
function escapeCQL(val) {
if (val === undefined || val === null) {
return 'NULL';
}
if(val instanceof Buffer){
return val.toString('hex');
}
if(typeof val === 'boolean' || typeof val === 'number'){
return val.toString();
}
if (Array.isArray(val)) {
var sanitized = val.map( function( v ) { return escapeCQL( v ); } );
return "'" + sanitized.join( "','" ) + "'";
}
if (typeof val === 'object') {
val = (typeof val.toISOString === 'function') ? val.toISOString() : val.toString();
}
val = val.replace(/[\0\n\r\b\t\\\'\"\x1a]/g, function(s) {
switch(s) {
case "\0": return "\\0";
case "\n": return "\\n";
case "\r": return "\\r";
case "\b": return "\\b";
case "\t": return "\\t";
case "\x1a": return "\\Z";
case "'": return "''";
default: return "\\"+s;
}
});
return "'"+val+"'";
}

@@ -369,9 +430,3 @@

if(args){
var i = 0;
for(; i < args.length; i += 1){
escaped.push(cqlEscape(args[i]));
}
escaped.unshift(cmd.replace(/\?/g, '%s'));
cql = new Buffer(util.format.apply(this, escaped));
cql = new Buffer(formatCQL(cmd, args));
} else {

@@ -378,0 +433,0 @@ cql = new Buffer(cmd);

4

package.json
{
"name": "helenus"
, "version": "0.4.0"
, "version": "0.5.0"
, "description": "NodeJS Bindings for Cassandra"

@@ -26,3 +26,3 @@ , "keywords": ["cassandra"]

, "main": "index"
, "engines": { "node": "0.6.x" }
, "engines": { "node": "0.6.x | 0.7.x" }
}

@@ -121,2 +121,3 @@

* columnFamily.remove
* columnFamily.truncate

@@ -128,3 +129,2 @@ The following support is going to be added in later releases:

* columnfamily.increment
* columnFamily.truncate
* SuperColumns

@@ -131,0 +131,0 @@ * CounterColumns

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc