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

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 = { ...@@ -365,7 +365,6 @@ var QueryGenerator = {
// handle self referential constraints // handle self referential constraints
if (attribute.references) { if (attribute.references) {
attribute = Utils.formatReferences(attribute);
if (attribute.Model && attribute.Model.tableName === attribute.references.model) { if (attribute.Model && attribute.Model.tableName === attribute.references.model) {
this.sequelize.log('MSSQL does not support self referencial constraints, ' this.sequelize.log('MSSQL does not support self referencial constraints, '
...@@ -445,7 +444,6 @@ var QueryGenerator = { ...@@ -445,7 +444,6 @@ var QueryGenerator = {
attribute = attributes[key]; attribute = attributes[key];
if (attribute.references) { if (attribute.references) {
attribute = Utils.formatReferences(attributes[key]);
if (existingConstraints.indexOf(attribute.references.model.toString()) !== -1) { if (existingConstraints.indexOf(attribute.references.model.toString()) !== -1) {
// no cascading constraints to a table more than once // no cascading constraints to a table more than once
......
...@@ -265,7 +265,6 @@ var QueryGenerator = { ...@@ -265,7 +265,6 @@ var QueryGenerator = {
} }
if (attribute.references) { if (attribute.references) {
attribute = Utils.formatReferences(attribute);
if (options && options.context === 'addColumn' && options.foreignKey) { if (options && options.context === 'addColumn' && options.foreignKey) {
var attrName = options.foreignKey; var attrName = options.foreignKey;
......
...@@ -481,7 +481,6 @@ var QueryGenerator = { ...@@ -481,7 +481,6 @@ var QueryGenerator = {
} }
if (attribute.references) { if (attribute.references) {
attribute = Utils.formatReferences(attribute);
template += ' REFERENCES <%= referencesTable %> (<%= referencesKey %>)'; template += ' REFERENCES <%= referencesTable %> (<%= referencesKey %>)';
replacements.referencesTable = this.quoteTable(attribute.references.model); replacements.referencesTable = this.quoteTable(attribute.references.model);
......
...@@ -206,7 +206,6 @@ var QueryGenerator = { ...@@ -206,7 +206,6 @@ var QueryGenerator = {
} }
if(dataType.references) { if(dataType.references) {
dataType = Utils.formatReferences(dataType);
template += ' REFERENCES <%= referencesTable %> (<%= referencesKey %>)'; template += ' REFERENCES <%= referencesTable %> (<%= referencesKey %>)';
replacements.referencesTable = this.quoteTable(dataType.references.model); replacements.referencesTable = this.quoteTable(dataType.references.model);
......
'use strict'; 'use strict';
var Toposort = require('toposort-class') var Toposort = require('toposort-class')
, Utils = require('./utils')
, _ = require('lodash'); , _ = require('lodash');
var ModelManager = function(sequelize) { var ModelManager = function(sequelize) {
...@@ -70,8 +69,7 @@ ModelManager.prototype.forEachModel = function(iterator, options) { ...@@ -70,8 +69,7 @@ ModelManager.prototype.forEachModel = function(iterator, options) {
var attribute = model.rawAttributes[attrName]; var attribute = model.rawAttributes[attrName];
if (attribute.references) { if (attribute.references) {
attribute = Utils.formatReferences(attribute); dep = attribute.references.model;
dep = attribute.references.model;
if (_.isObject(dep)) { if (_.isObject(dep)) {
dep = dep.schema + '.' + dep.tableName; dep = dep.schema + '.' + dep.tableName;
......
...@@ -84,7 +84,6 @@ var Model = function(name, attributes, options) { ...@@ -84,7 +84,6 @@ var Model = function(name, attributes, options) {
attribute = this.sequelize.normalizeAttribute(attribute); attribute = this.sequelize.normalizeAttribute(attribute);
if (attribute.references) { if (attribute.references) {
attribute = Utils.formatReferences(attribute);
if (attribute.references.model instanceof Model) { if (attribute.references.model instanceof Model) {
attribute.references.model = attribute.references.model.tableName; attribute.references.model = attribute.references.model.tableName;
......
...@@ -6,7 +6,6 @@ var DataTypes = require('./data-types') ...@@ -6,7 +6,6 @@ var DataTypes = require('./data-types')
, parameterValidator = require('./utils/parameter-validator') , parameterValidator = require('./utils/parameter-validator')
, inflection = require('inflection') , inflection = require('inflection')
, uuid = require('node-uuid') , uuid = require('node-uuid')
, deprecate = require('depd')('Utils')
, primitives = ['string', 'number', 'boolean']; , primitives = ['string', 'number', 'boolean'];
var Utils = module.exports = { var Utils = module.exports = {
...@@ -450,18 +449,7 @@ var Utils = module.exports = { ...@@ -450,18 +449,7 @@ var Utils = module.exports = {
this.logic = logic; this.logic = logic;
}, },
validateParameter: parameterValidator, 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;
}
}; };
Utils.where.prototype._isSequelizeMethod = 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!