src/nrutil.js
function parseSQLVal(type, val) {
	if (val == 'NULL') {
		return null;
	}

	switch (type) {
		case 'datetime':
		case 'timestamp':
			if (val == 'CURRENT_TIMESTAMP') {
				return val;
            } else if (val == '0000-00-00 00:00:00') {
                // HACK(arlen): Not sure if this is correct, but constructing
                // a Date out of this yields "Invalid Date".
                return null;
			} else {
				return new Date(val);
			}
		case 'text':
		case 'string':
			return val;
		case 'integer':
		case 'primary_key':
			return parseInt(val);
		case 'float':
			return parseFloat(val);
		case 'boolean':
			return (val == "TRUE");
		default:
			throw "Unknown friendly type `" + type + "`!";
	}
}
function parseSQLVal(type, val) {
	if (val == 'NULL') {
		return null;
	}

	switch (type) {
		case 'datetime':
		case 'timestamp':
			if (val == 'CURRENT_TIMESTAMP') {
				return val;
            } else if (val == '0000-00-00 00:00:00') {
                // HACK(arlen): Not sure if this is correct, but constructing
                // a Date out of this yields "Invalid Date".
                return null;
			} else {
				return new Date(val);
			}
		case 'text':
		case 'string':
			return val;
		case 'integer':
		case 'primary_key':
			return parseInt(val);
		case 'float':
			return parseFloat(val);
		case 'boolean':
			return (val == "TRUE");
		default:
			throw "Unknown friendly type `" + type + "`!";
	}
}
function parseSQLVal ( type , val ) { if ( val == 'NULL' ) { return null ; } switch ( type ) { case 'datetime' : case 'timestamp' : if ( val == 'CURRENT_TIMESTAMP' ) { return val ; } else if ( val == '0000-00-00 00:00:00' ) { // HACK(arlen): Not sure if this is correct, but constructing // a Date out of this yields "Invalid Date". return null ; } else { return new Date ( val ) ; } case 'text' : case 'string' : return val ; case 'integer' : case 'primary_key' : return parseInt ( val ) ; case 'float' : return parseFloat ( val ) ; case 'boolean' : return ( val == "TRUE" ) ; default : throw "Unknown friendly type `" + type + "`!" ; } }
Parses an SQL string into a JS object given the friendly type.
Parses an SQL string into a JS object given the friendly type .