src/model.js
function setValue(key, val) {
			//util.log(key + ": " + JSON.stringify(val));

			if (val === null) {
				me.values[key] = null;
			} else if (val === undefined) {
				me.values[key] = undefined;
			} else {
				type = model.columns[key]['DATA_TYPE'];

				switch (type) {
					case 'datetime':
					case 'timestamp':
						me.values[key] = new Date(val);
						break;
					case 'text':
					case 'varchar':
						me.values[key] = val.toString();
						break;
					case 'int':
					case 'tinyint':
						if (model.columns[key]['COLUMN_TYPE'] == 'tinyint(1)') {
							me.values[key] = !!val // Boolean
						} else {
							me.values[key] = parseInt(val);
						}
						break;
					default:
						me.values[key] = val;
				}
			}
		}
function setValue(key, val) {
			//util.log(key + ": " + JSON.stringify(val));

			if (val === null) {
				me.values[key] = null;
			} else if (val === undefined) {
				me.values[key] = undefined;
			} else {
				type = model.columns[key]['DATA_TYPE'];

				switch (type) {
					case 'datetime':
					case 'timestamp':
						me.values[key] = new Date(val);
						break;
					case 'text':
					case 'varchar':
						me.values[key] = val.toString();
						break;
					case 'int':
					case 'tinyint':
						if (model.columns[key]['COLUMN_TYPE'] == 'tinyint(1)') {
							me.values[key] = !!val // Boolean
						} else {
							me.values[key] = parseInt(val);
						}
						break;
					default:
						me.values[key] = val;
				}
			}
		}
function setValue ( key , val ) { //util.log(key + ": " + JSON.stringify(val)); if ( val === null ) { me . values [ key ] = null ; } else if ( val === undefined ) { me . values [ key ] = undefined ; } else { type = model . columns [ key ] [ 'DATA_TYPE' ] ; switch ( type ) { case 'datetime' : case 'timestamp' : me . values [ key ] = new Date ( val ) ; break ; case 'text' : case 'varchar' : me . values [ key ] = val . toString ( ) ; break ; case 'int' : case 'tinyint' : if ( model . columns [ key ] [ 'COLUMN_TYPE' ] == 'tinyint(1)' ) { me . values [ key ] = ! ! val // Boolean } else { me . values [ key ] = parseInt ( val ) ; } break ; default : me . values [ key ] = val ; } } }
Generic setter for SQL-correspondent values. Forces typecasting for database compatibility.
Generic setter for SQL - correspondent values . Forces typecasting for database compatibility .