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

Commit 8a6b9b08 by Sushant

refactor: errors.js

1 parent 1bcfaa70
......@@ -4,7 +4,7 @@ const Utils = require('../../utils');
const debug = Utils.getLogger().debugContext('sql:mssql');
const Promise = require('../../promise');
const AbstractQuery = require('../abstract/query');
const sequelizeErrors = require('../../errors.js');
const sequelizeErrors = require('../../errors');
const parserStore = require('../parserStore')('mssql');
const _ = require('lodash');
const TYPES = require('tedious').TYPES;
......
......@@ -4,7 +4,7 @@ const Utils = require('../../utils');
const debug = Utils.getLogger().debugContext('sql:mysql');
const AbstractQuery = require('../abstract/query');
const uuid = require('uuid');
const sequelizeErrors = require('../../errors.js');
const sequelizeErrors = require('../../errors');
const _ = require('lodash');
class Query extends AbstractQuery {
......
......@@ -5,7 +5,7 @@ const debug = Utils.getLogger().debugContext('sql:pg');
const AbstractQuery = require('../abstract/query');
const QueryTypes = require('../../query-types');
const Promise = require('../../promise');
const sequelizeErrors = require('../../errors.js');
const sequelizeErrors = require('../../errors');
const _ = require('lodash');
class Query extends AbstractQuery {
......
......@@ -6,7 +6,7 @@ const debug = Utils.getLogger().debugContext('sql:sqlite');
const Promise = require('../../promise');
const AbstractQuery = require('../abstract/query');
const QueryTypes = require('../../query-types');
const sequelizeErrors = require('../../errors.js');
const sequelizeErrors = require('../../errors');
const parserStore = require('../parserStore')('sqlite');
class Query extends AbstractQuery {
......
'use strict';
module.exports = require('./errors/index.js');
'use strict';
const _ = require('lodash');
/**
* Sequelize provides a host of custom error classes, to allow you to do easier debugging. All of these errors are exposed on the sequelize object and the sequelize constructor.
* All sequelize errors inherit from the base JS error object.
......@@ -299,7 +297,7 @@ class ValidationErrorItem {
if (ValidationErrorItem.Origins[ type ]) {
this.origin = type;
} else {
const lowercaseType = _.toLower(type + '').trim();
const lowercaseType = (type + '').toLowerCase().trim();
const realType = ValidationErrorItem.TypeStringMap[ lowercaseType ];
if (realType && ValidationErrorItem.Origins[ realType ]) {
......@@ -342,7 +340,7 @@ class ValidationErrorItem {
return '';
}
return _.toLower(useNS ? [type, key].join(NSSep) : key).trim();
return (useNS ? [type, key].join(NSSep) : key).toLowerCase().trim();
}
}
......
......@@ -18,7 +18,6 @@ const defaultsOptions = { raw: true };
const assert = require('assert');
const Op = require('./operators');
/**
* A Model represents a table in the database. Instances of this class represent a database row.
*
......@@ -809,7 +808,7 @@ class Model {
* @param {String} [options.indexes[].type] Index type. Only used by mysql. One of `UNIQUE`, `FULLTEXT` and `SPATIAL`
* @param {String} [options.indexes[].method] The method to create the index by (`USING` statement in SQL). BTREE and HASH are supported by mysql and postgres, and postgres additionally supports GIST and GIN.
* @param {Boolean} [options.indexes[].unique=false] Should the index by unique? Can also be triggered by setting type to `UNIQUE`
* @param {Boolean} [options.indexes[].concurrently=false] PostgreSQL will build the index without taking any write locks. Postgres only
* @param {Boolean} [options.indexes[].concurrently=false] PostgresSQL will build the index without taking any write locks. Postgres only
* @param {Array<String|Object>} [options.indexes[].fields] An array of the fields to index. Each field can either be a string containing the name of the field, a sequelize object (e.g `sequelize.fn`), or an object with the following attributes: `attribute` (field name), `length` (create a prefix index of length chars), `order` (the direction the column should be sorted in), `collate` (the collation (sort order) for the column)
* @param {String|Boolean} [options.createdAt] Override the name of the createdAt attribute if a string is provided, or disable it if false. Timestamps must be true. Underscored field will be set with underscored setting.
* @param {String|Boolean} [options.updatedAt] Override the name of the updatedAt attribute if a string is provided, or disable it if false. Timestamps must be true. Underscored field will be set with underscored setting.
......@@ -821,7 +820,7 @@ class Model {
* @param {String} [options.comment]
* @param {String} [options.collate]
* @param {String} [options.initialAutoIncrement] Set the initial AUTO_INCREMENT value for the table in MySQL.
* @param {Object} [options.hooks] An object of hook function that are called before and after certain lifecycle events. The possible hooks are: beforeValidate, afterValidate, validationFailed, beforeBulkCreate, beforeBulkDestroy, beforeBulkUpdate, beforeCreate, beforeDestroy, beforeUpdate, afterCreate, afterDestroy, afterUpdate, afterBulkCreate, afterBulkDestory and afterBulkUpdate. See Hooks for more information about hook functions and their signatures. Each property can either be a function, or an array of functions.
* @param {Object} [options.hooks] An object of hook function that are called before and after certain lifecycle events. The possible hooks are: beforeValidate, afterValidate, validationFailed, beforeBulkCreate, beforeBulkDestroy, beforeBulkUpdate, beforeCreate, beforeDestroy, beforeUpdate, afterCreate, afterDestroy, afterUpdate, afterBulkCreate, afterBulkDestroy and afterBulkUpdate. See Hooks for more information about hook functions and their signatures. Each property can either be a function, or an array of functions.
* @param {Object} [options.validate] An object of model wide validations. Validations have access to all model values via `this`. If the validator function takes an argument, it is assumed to be async, and is called with a callback that accepts an optional error.
* @return {Model}
......
......@@ -709,7 +709,7 @@ class Sequelize {
if (model) {
models.push(model);
} else {
// DB should throw an SQL error if referencing inexistant table
// DB should throw an SQL error if referencing non-existent table
}
});
......
......@@ -8,9 +8,9 @@
* @private
*/
const depd = require('depd'),
debug = require('debug'),
_ = require('lodash');
const depd = require('depd');
const debug = require('debug');
const _ = require('lodash');
class Logger {
constructor(config) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!