不要怂,就是干,撸起袖子干!

Commit efc54f4f by Sushant Committed by Jan Aagaard Meier

(cleanup) removed referenceKey support, using references object

1 parent a923048f
......@@ -365,7 +365,6 @@ var QueryGenerator = {
// handle self referential constraints
if (attribute.references) {
attribute = Utils.formatReferences(attribute);
if (attribute.Model && attribute.Model.tableName === attribute.references.model) {
this.sequelize.log('MSSQL does not support self referencial constraints, '
......@@ -445,7 +444,6 @@ var QueryGenerator = {
attribute = attributes[key];
if (attribute.references) {
attribute = Utils.formatReferences(attributes[key]);
if (existingConstraints.indexOf(attribute.references.model.toString()) !== -1) {
// no cascading constraints to a table more than once
......
......@@ -265,7 +265,6 @@ var QueryGenerator = {
}
if (attribute.references) {
attribute = Utils.formatReferences(attribute);
if (options && options.context === 'addColumn' && options.foreignKey) {
var attrName = options.foreignKey;
......
......@@ -481,7 +481,6 @@ var QueryGenerator = {
}
if (attribute.references) {
attribute = Utils.formatReferences(attribute);
template += ' REFERENCES <%= referencesTable %> (<%= referencesKey %>)';
replacements.referencesTable = this.quoteTable(attribute.references.model);
......
......@@ -206,7 +206,6 @@ var QueryGenerator = {
}
if(dataType.references) {
dataType = Utils.formatReferences(dataType);
template += ' REFERENCES <%= referencesTable %> (<%= referencesKey %>)';
replacements.referencesTable = this.quoteTable(dataType.references.model);
......
'use strict';
var Toposort = require('toposort-class')
, Utils = require('./utils')
, _ = require('lodash');
var ModelManager = function(sequelize) {
......@@ -70,8 +69,7 @@ ModelManager.prototype.forEachModel = function(iterator, options) {
var attribute = model.rawAttributes[attrName];
if (attribute.references) {
attribute = Utils.formatReferences(attribute);
dep = attribute.references.model;
dep = attribute.references.model;
if (_.isObject(dep)) {
dep = dep.schema + '.' + dep.tableName;
......
......@@ -84,7 +84,6 @@ var Model = function(name, attributes, options) {
attribute = this.sequelize.normalizeAttribute(attribute);
if (attribute.references) {
attribute = Utils.formatReferences(attribute);
if (attribute.references.model instanceof Model) {
attribute.references.model = attribute.references.model.tableName;
......
......@@ -6,7 +6,6 @@ var DataTypes = require('./data-types')
, parameterValidator = require('./utils/parameter-validator')
, inflection = require('inflection')
, uuid = require('node-uuid')
, deprecate = require('depd')('Utils')
, primitives = ['string', 'number', 'boolean'];
var Utils = module.exports = {
......@@ -450,18 +449,7 @@ var Utils = module.exports = {
this.logic = logic;
},
validateParameter: parameterValidator,
formatReferences: function (obj) {
if (!_.isPlainObject(obj.references)) {
deprecate('Non-object references property found. Support for that will be removed in version 4. Expected { references: { model: "value", key: "key" } } instead of { references: "value", referencesKey: "key" }.');
obj.references = { model: obj.references, key: obj.referencesKey, deferrable: obj.referencesDeferrable };
obj.referencesKey = undefined;
obj.referencesDeferrable = undefined;
}
return obj;
}
validateParameter: parameterValidator
};
Utils.where.prototype._isSequelizeMethod =
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!