Commit 379112bc603117be3c93912b83194029a4ad0992

Authored by 陈亮
2 parents fef31883 4d9755dd

Merge branch 'master' into version2.2

Conflicts:
	package.json
lib/Drivers/DML/mysql.js
... ... @@ -259,7 +259,7 @@ Driver.prototype.valueToProperty = function (value, property) {
259 259 default:
260 260 customType = this.customTypes[property.type];
261 261 if(customType && 'valueToProperty' in customType) {
262   - value = customType.valueToProperty(value);
  262 + value = customType.valueToProperty(value,property);
263 263 }
264 264 }
265 265 return value;
... ... @@ -283,7 +283,7 @@ Driver.prototype.propertyToValue = function (value, property) {
283 283 default:
284 284 customType = this.customTypes[property.type];
285 285 if(customType && 'propertyToValue' in customType) {
286   - value = customType.propertyToValue(value);
  286 + value = customType.propertyToValue(value,property);
287 287 }
288 288 }
289 289 return value;
... ...
lib/Instance.js
... ... @@ -493,34 +493,36 @@ function Instance(Model, opts) {
493 493 } else if (prop && 'defaultValue' in prop) {
494 494 defaultValue = prop.defaultValue;
495 495 }
  496 + if(opts.data=={} || key in opts.data)
  497 + {
  498 + setInstanceProperty(key, defaultValue);
  499 +
  500 + Object.defineProperty(instance, key, {
  501 + get: function () {
  502 + return opts.data[key];
  503 + },
  504 + set: function (val) {
  505 + if (prop.key === true) {
  506 + if (prop.type == 'serial' && opts.data[key] != null) {
  507 + return;
  508 + } else {
  509 + opts.originalKeyValues[prop.name] = opts.data[prop.name];
  510 + }
  511 + }
496 512  
497   - setInstanceProperty(key, defaultValue);
498   -
499   - Object.defineProperty(instance, key, {
500   - get: function () {
501   - return opts.data[key];
502   - },
503   - set: function (val) {
504   - if (prop.key === true) {
505   - if (prop.type == 'serial' && opts.data[key] != null) {
  513 + if (!setInstanceProperty(key, val)) {
506 514 return;
507   - } else {
508   - opts.originalKeyValues[prop.name] = opts.data[prop.name];
509 515 }
510   - }
511 516  
512   - if (!setInstanceProperty(key, val)) {
513   - return;
514   - }
515   -
516   - if (opts.autoSave) {
517   - saveInstanceProperty(key, val);
518   - } else if (opts.changes.indexOf(key) === -1) {
519   - opts.changes.push(key);
520   - }
521   - },
522   - enumerable: true
523   - });
  517 + if (opts.autoSave) {
  518 + saveInstanceProperty(key, val);
  519 + } else if (opts.changes.indexOf(key) === -1) {
  520 + opts.changes.push(key);
  521 + }
  522 + },
  523 + enumerable: true
  524 + });
  525 + }
524 526 };
525 527 var addInstanceExtraProperty = function (key) {
526 528 if (!instance.hasOwnProperty("extra")) {
... ...
package.json
... ... @@ -46,11 +46,11 @@
46 46 "mysql" : "2.9.0",
47 47 "pg" : "4.4.3",
48 48 "sqlite3" : "3.1.0",
49   - "async" : "0.9.0",
50   - "mocha" : "1.13.0",
  49 + "async" : "1.5.0",
  50 + "mocha" : "2.3.3",
51 51 "should" : "1.2.2",
52 52 "mongodb" : "1.3.19",
53   - "glob" : "3.2.8"
  53 + "glob" : "5.0.15"
54 54 },
55 55 "optionalDependencies": {}
56 56 }
... ...