Make sure foreign key properties are fully registered

This commit is contained in:
Raymond Feng 2013-10-07 18:01:31 -07:00
parent 0bfc362b18
commit b8f94f5777
1 changed files with 5 additions and 4 deletions

View File

@ -1256,7 +1256,8 @@ DataSource.prototype.defineForeignKey = function defineForeignKey(className, key
if (this.connector.defineForeignKey) { if (this.connector.defineForeignKey) {
var cb = function (err, keyType) { var cb = function (err, keyType) {
if (err) throw err; if (err) throw err;
this.definitions[className].defineProperty(key, {type: keyType}); // Add the foreign key property to the data source _models
this.defineProperty(className, key, {type: keyType || Number});
}.bind(this); }.bind(this);
switch (this.connector.defineForeignKey.length) { switch (this.connector.defineForeignKey.length) {
case 4: case 4:
@ -1268,10 +1269,10 @@ DataSource.prototype.defineForeignKey = function defineForeignKey(className, key
break; break;
} }
} else { } else {
this.definitions[className].defineProperty(key, {type: Number}); // Add the foreign key property to the data source _models
this.defineProperty(className, key, {type: Number});
} }
this.models[className].registerProperty(key);
}; };
/** /**