Merge pull request #715 from nennad/master

foreignKey dataLength fix
This commit is contained in:
Raymond Feng 2015-11-26 09:28:08 -08:00
commit 486c1de1ba
1 changed files with 7 additions and 2 deletions

View File

@ -1816,10 +1816,15 @@ DataSource.prototype.defineForeignKey = function defineForeignKey(className, key
var fkDef = {type: pkType}; var fkDef = {type: pkType};
var foreignMeta = this.columnMetadata(foreignClassName, pkName); var foreignMeta = this.columnMetadata(foreignClassName, pkName);
if(foreignMeta && foreignMeta.dataType) { if (foreignMeta && (foreignMeta.dataType || foreignMeta.dataLength)) {
fkDef[this.connector.name] = {}; fkDef[this.connector.name] = {};
if (foreignMeta.dataType) {
fkDef[this.connector.name].dataType = foreignMeta.dataType; fkDef[this.connector.name].dataType = foreignMeta.dataType;
} }
if (foreignMeta.dataLength) {
fkDef[this.connector.name].dataLength = foreignMeta.dataLength;
}
}
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;