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

Commit 25d7d3cb by overlookmotel

Tests hints for options shimming

1 parent 760eb59e
...@@ -97,7 +97,7 @@ var Mixin = module.exports = function() {}; ...@@ -97,7 +97,7 @@ var Mixin = module.exports = function() {};
// The logic for hasOne and belongsTo is exactly the same // The logic for hasOne and belongsTo is exactly the same
var singleLinked = function (Type) { var singleLinked = function (Type) {
return function(targetModel, options) { return function(targetModel, options) { // testhint options:none
if (!(targetModel instanceof this.sequelize.Model)) { if (!(targetModel instanceof this.sequelize.Model)) {
throw new Error(this.name + '.' + Utils.lowercaseFirst(Type.toString()) + ' called with something that\'s not an instance of Sequelize.Model'); throw new Error(this.name + '.' + Utils.lowercaseFirst(Type.toString()) + ' called with something that\'s not an instance of Sequelize.Model');
} }
...@@ -244,7 +244,7 @@ Mixin.belongsTo = singleLinked(BelongsTo); ...@@ -244,7 +244,7 @@ Mixin.belongsTo = singleLinked(BelongsTo);
* @param {string} [options.onUpdate='CASCADE'] * @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key. * @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
*/ */
Mixin.hasMany = function(targetModel, options) { Mixin.hasMany = function(targetModel, options) { // testhint options:none
if (!(targetModel instanceof this.sequelize.Model)) { if (!(targetModel instanceof this.sequelize.Model)) {
throw new Error(this.name + '.hasMany called with something that\'s not an instance of Sequelize.Model'); throw new Error(this.name + '.hasMany called with something that\'s not an instance of Sequelize.Model');
} }
...@@ -338,7 +338,7 @@ Mixin.hasMany = function(targetModel, options) { ...@@ -338,7 +338,7 @@ Mixin.hasMany = function(targetModel, options) {
* @param {string} [options.onUpdate='CASCADE'] * @param {string} [options.onUpdate='CASCADE']
* @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key. * @param {boolean} [options.constraints=true] Should on update and on delete constraints be enabled on the foreign key.
*/ */
Mixin.belongsToMany = function(targetModel, options) { Mixin.belongsToMany = function(targetModel, options) { // testhint options:none
if (!(targetModel instanceof this.sequelize.Model)) { if (!(targetModel instanceof this.sequelize.Model)) {
throw new Error(this.name + '.belongsToMany called with something that\'s not an instance of Sequelize.Model'); throw new Error(this.name + '.belongsToMany called with something that\'s not an instance of Sequelize.Model');
} }
......
...@@ -176,7 +176,7 @@ Instance.prototype.setDataValue = function(key, value) { ...@@ -176,7 +176,7 @@ Instance.prototype.setDataValue = function(key, value) {
* @param {Boolean} [options.plain=false] If set to true, included instances will be returned as plain objects * @param {Boolean} [options.plain=false] If set to true, included instances will be returned as plain objects
* @return {Object|any} * @return {Object|any}
*/ */
Instance.prototype.get = function(key, options) { Instance.prototype.get = function(key, options) { // testhint options:none
if (options === undefined && typeof key === 'object') { if (options === undefined && typeof key === 'object') {
options = key; options = key;
key = undefined; key = undefined;
...@@ -246,7 +246,7 @@ Instance.prototype.get = function(key, options) { ...@@ -246,7 +246,7 @@ Instance.prototype.get = function(key, options) {
* @param {Boolean} [options.reset=false] Clear all previously set data values * @param {Boolean} [options.reset=false] Clear all previously set data values
* @alias setAttributes * @alias setAttributes
*/ */
Instance.prototype.set = function(key, value, options) { Instance.prototype.set = function(key, value, options) { // testhint options:none
var values var values
, originalValue , originalValue
, keys , keys
......
...@@ -919,7 +919,7 @@ Model.prototype.dropSchema = function(schema) { ...@@ -919,7 +919,7 @@ Model.prototype.dropSchema = function(schema) {
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql. * @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @return {this} * @return {this}
*/ */
Model.prototype.schema = function(schema, options) { Model.prototype.schema = function(schema, options) { // testhint options:none
this.options.schema = schema; this.options.schema = schema;
if (!!options) { if (!!options) {
...@@ -943,7 +943,7 @@ Model.prototype.schema = function(schema, options) { ...@@ -943,7 +943,7 @@ Model.prototype.schema = function(schema, options) {
* @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql. * @param {Function} [options.logging=false] A function that gets executed while running the query to log the sql.
* @return {String|Object} * @return {String|Object}
*/ */
Model.prototype.getTableName = function(options) { Model.prototype.getTableName = function(options) { // testhint options:none
return this.QueryGenerator.addSchema(this); return this.QueryGenerator.addSchema(this);
}; };
...@@ -1394,7 +1394,7 @@ Model.prototype.count = function(options) { ...@@ -1394,7 +1394,7 @@ Model.prototype.count = function(options) {
* @return {Promise<Object>} * @return {Promise<Object>}
* @alias findAndCountAll * @alias findAndCountAll
*/ */
Model.prototype.findAndCount = function(findOptions) { Model.prototype.findAndCount = function(findOptions) { // testhint options:1
if (findOptions !== undefined && !_.isPlainObject(findOptions)) { if (findOptions !== undefined && !_.isPlainObject(findOptions)) {
throw new Error('The argument passed to findAndCount must be an options object, use findById if you wish to pass a single primary key value'); throw new Error('The argument passed to findAndCount must be an options object, use findById if you wish to pass a single primary key value');
} }
...@@ -1499,7 +1499,7 @@ Model.prototype.sum = function(field, options) { ...@@ -1499,7 +1499,7 @@ Model.prototype.sum = function(field, options) {
* *
* @return {Instance} * @return {Instance}
*/ */
Model.prototype.build = function(values, options) { Model.prototype.build = function(values, options) { // testhint options:none
if (Array.isArray(values)) { if (Array.isArray(values)) {
return this.bulkBuild(values, options); return this.bulkBuild(values, options);
} }
...@@ -1525,7 +1525,7 @@ Model.prototype.build = function(values, options) { ...@@ -1525,7 +1525,7 @@ Model.prototype.build = function(values, options) {
}; };
Model.prototype.bulkBuild = function(valueSets, options) { Model.prototype.bulkBuild = function(valueSets, options) { // testhint options:none
options = _.extend({ options = _.extend({
isNewRecord: true isNewRecord: true
}, options || {}); }, options || {});
......
...@@ -437,6 +437,7 @@ QueryInterface.prototype.addIndex = function(tableName, attributes, options, raw ...@@ -437,6 +437,7 @@ QueryInterface.prototype.addIndex = function(tableName, attributes, options, raw
options = attributes; options = attributes;
attributes = options.fields; attributes = options.fields;
} }
// testhint argsConform.end
if (!rawTablename) { if (!rawTablename) {
// Map for backwards compat // Map for backwards compat
......
...@@ -511,7 +511,7 @@ Sequelize.prototype.getQueryInterface = function() { ...@@ -511,7 +511,7 @@ Sequelize.prototype.getQueryInterface = function() {
* *
* @return {Model} * @return {Model}
*/ */
Sequelize.prototype.define = function(modelName, attributes, options) { Sequelize.prototype.define = function(modelName, attributes, options) { // testhint options:none
options = options || {}; options = options || {};
var globalOptions = this.options; var globalOptions = this.options;
...@@ -1123,6 +1123,7 @@ Sequelize.prototype.transaction = function(options, autoCallback) { ...@@ -1123,6 +1123,7 @@ Sequelize.prototype.transaction = function(options, autoCallback) {
autoCallback = options; autoCallback = options;
options = undefined; options = undefined;
} }
// testhint argsConform.end
var transaction = new Transaction(this, options) var transaction = new Transaction(this, options)
, ns = Sequelize.cls; , ns = Sequelize.cls;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!