src/nrutil.js
function serialize(val) {
	if (val == null) {
		return 'NULL'

	} else if (typeof val == 'string') {
		return "'" + val.replace(/(\\)/g, '\\$1').replace(/(')/g, '\\$1') + "'";
	
	} else if (typeof val == 'number') {
		if (isNaN(val)) {
			return 'NULL';
		} else {
			return val.toString();
		}

	} else if ([true, false].indexOf(val) != -1) {
		return val.toString().toUpperCase();

	} else if (val instanceof Date) {
		return "'" + makeDateStr(val) + "'";

	} else {
		throw "Unable to serialize variable of type `" + typeof val + "`!";
	}
}
function serialize(val) {
	if (val == null) {
		return 'NULL'

	} else if (typeof val == 'string') {
		return "'" + val.replace(/(\\)/g, '\\$1').replace(/(')/g, '\\$1') + "'";
	
	} else if (typeof val == 'number') {
		if (isNaN(val)) {
			return 'NULL';
		} else {
			return val.toString();
		}

	} else if ([true, false].indexOf(val) != -1) {
		return val.toString().toUpperCase();

	} else if (val instanceof Date) {
		return "'" + makeDateStr(val) + "'";

	} else {
		throw "Unable to serialize variable of type `" + typeof val + "`!";
	}
}
function serialize ( val ) { if ( val == null ) { return 'NULL' } else if ( typeof val == 'string' ) { return "'" + val . replace ( / (\\) / g , '\\$1' ) . replace ( / (') / g , '\\$1' ) + "'" ; } else if ( typeof val == 'number' ) { if ( isNaN ( val ) ) { return 'NULL' ; } else { return val . toString ( ) ; } } else if ( [ true , false ] . indexOf ( val ) != - 1 ) { return val . toString ( ) . toUpperCase ( ) ; } else if ( val instanceof Date ) { return "'" + makeDateStr ( val ) + "'" ; } else { throw "Unable to serialize variable of type `" + typeof val + "`!" ; } }
Attempt to serialize a value as a string acceptable for an SQL statement.
Attempt to serialize a value as a string acceptable for an SQL statement .