Comparing version 0.1.17 to 0.1.18
{ | ||
"name": "yorm", | ||
"version": "0.1.17", | ||
"version": "0.1.18", | ||
"dependencies": { | ||
@@ -5,0 +5,0 @@ "bluebird": "^3.4.6", |
41
test.js
@@ -12,5 +12,27 @@ var yorm = require("./yorm") | ||
// tt.value = 'value ' + tt.id | ||
tt.value = 'testing value to be overridden' | ||
tt.value = 't' + tt.id | ||
ta.push(tt) | ||
} | ||
yorm.query('delete from zz').then(function() { | ||
return new Promise(function(resolve, reject) { | ||
yorm.saveone('zz', {'id':0, 'value': 0}).then(function(){ | ||
resolve() | ||
}) | ||
}) | ||
}).then(function() { | ||
return new Promise(function(resolve, reject) { | ||
yorm.savemany('zz', ta).then(function(){ | ||
resolve() | ||
}) | ||
}) | ||
}).then(function() { | ||
yorm.getmany('zz', '').then(function(rs){ | ||
console.log('Database contents after insert by saveone and savemany: ' + JSON.stringify(rs)) | ||
process.exit(0) | ||
}) | ||
}).catch(function(e) { | ||
console.log('error in savemany, saveone, getmany: ' + e) | ||
process.exit(-1) | ||
}) | ||
// yorm.refreshByKey('zz', ta, ['value'], {'id': 'asc'}, 100).then(function() { | ||
@@ -25,15 +47,8 @@ // console.log('ta: ' + JSON.stringify(ta)) | ||
// }) | ||
yorm.getone('zz', {'id': 9}).then(function(value) { | ||
console.log('after getone value: ' + JSON.stringify(value)) | ||
}).catch(function(e) { | ||
console.log("getone failed" + e) | ||
}) | ||
yorm.getone('zz', {'id': 9}).then(function(value) { | ||
console.log('after getone value: ' + JSON.stringify(value)) | ||
}).catch(function(e) { | ||
console.log("getone failed" + e) | ||
}) | ||
var typea = yorm.defType('ekko', {'ebeln': {'ref': 'ot1ekko.ebeln'}, 'lifnr' : {'ref': 'ot1ekko.lifnr'}}) | ||
// var typea = yorm.defType('ekko', {'ebeln': {'ref': 'ot1ekko.ebeln'}, 'lifnr' : {'ref': 'ot1ekko.lifnr'}}) | ||
} | ||
setTimeout(test, 200) | ||
yorm.bufferinit().then(function() { | ||
test() | ||
}) | ||
//setTimeout(test, 200) //You donot have to call bufferinit always if you call is certain time after yorm loading. | ||
17
yorm.js
@@ -612,6 +612,15 @@ // var pool = require("./dbconfig") | ||
sfld = sfld + key + ', ' | ||
if (one[key] == undefined || one[key] == null) { | ||
sval = sval + null + ', ' | ||
var dt = cols0[key].dt; | ||
if (one[key] !== undefined && one[key] !== null) { | ||
if (numtypes.indexOf(dt) < 0) { | ||
sval = sval + "'" + one[key] + "', "; | ||
} else { | ||
if (isNaN(one[key])) { | ||
reject(tn + "." + key + " must be numeric. But the encountered is: " + one[key]); | ||
return | ||
} | ||
sval = sval + one[key] + ", "; | ||
} | ||
} else { | ||
sval = sval + '"' + one[key] + '", ' | ||
sval = sval + "null, " | ||
} | ||
@@ -691,3 +700,3 @@ } | ||
var dt = tblcols[key].dt; | ||
if (one[key]) { | ||
if (one[key] !== undefined && one[key] !== null) { | ||
if (numtypes.indexOf(dt) < 0) { | ||
@@ -694,0 +703,0 @@ svaluesone = svaluesone + "'" + one[key] + "', "; |
Sorry, the diff of this file is not supported yet
74481
801