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

Commit 9bc6d425 by supperchong Committed by Sushant

chores(styling): add spacing around infix operators rules in eslint (#11282)

1 parent 748f6908
...@@ -34,23 +34,12 @@ ...@@ -34,23 +34,12 @@
"properties": false "properties": false
} }
], ],
"semi": [ "semi": ["error", "always"],
"error", "space-before-function-paren": ["error", "never"],
"always"
],
"space-before-function-paren": [
"error",
"never"
],
"space-before-blocks": "error", "space-before-blocks": "error",
"arrow-parens": [ "space-infix-ops": "error",
"error", "arrow-parens": ["error", "as-needed"],
"as-needed" "comma-style": ["error", "last"],
],
"comma-style": [
"error",
"last"
],
"indent": [ "indent": [
"error", "error",
2, 2,
...@@ -73,25 +62,16 @@ ...@@ -73,25 +62,16 @@
// functional // functional
"valid-jsdoc": "off", "valid-jsdoc": "off",
"strict": [ "strict": ["error", "global"],
"error",
"global"
],
"no-var": "error", "no-var": "error",
"prefer-const": "error", "prefer-const": "error",
"prefer-arrow-callback": "error", "prefer-arrow-callback": "error",
"no-extend-native": "error", "no-extend-native": "error",
"wrap-iife": [ "wrap-iife": ["error", "any"],
"error",
"any"
],
"no-use-before-define": "off", "no-use-before-define": "off",
"no-caller": "error", "no-caller": "error",
"no-irregular-whitespace": "error", "no-irregular-whitespace": "error",
"max-depth": [ "max-depth": ["error", 6],
"error",
6
],
"no-loop-func": "warn", "no-loop-func": "warn",
"object-shorthand": "error", "object-shorthand": "error",
"one-var-declaration-per-line": "error", "one-var-declaration-per-line": "error",
...@@ -116,10 +96,7 @@ ...@@ -116,10 +96,7 @@
"ecmaVersion": 6, "ecmaVersion": 6,
"sourceType": "script" "sourceType": "script"
}, },
"plugins": [ "plugins": ["mocha", "jsdoc"],
"mocha",
"jsdoc"
],
"env": { "env": {
"node": true, "node": true,
"mocha": true, "mocha": true,
......
...@@ -346,7 +346,7 @@ class QueryGenerator { ...@@ -346,7 +346,7 @@ class QueryGenerator {
const values = []; const values = [];
const bind = []; const bind = [];
const modelAttributeMap = {}; const modelAttributeMap = {};
let outputFragment =''; let outputFragment = '';
let tmpTable = ''; // tmpTable declaration for trigger let tmpTable = ''; // tmpTable declaration for trigger
let selectFromTmp = ''; // Select statement for trigger let selectFromTmp = ''; // Select statement for trigger
let suffix = ''; let suffix = '';
...@@ -2197,7 +2197,7 @@ class QueryGenerator { ...@@ -2197,7 +2197,7 @@ class QueryGenerator {
// OR/AND/NOT grouping logic // OR/AND/NOT grouping logic
_whereGroupBind(key, value, options) { _whereGroupBind(key, value, options) {
const binding = key === Op.or ? this.OperatorMap[Op.or] : this.OperatorMap[Op.and]; const binding = key === Op.or ? this.OperatorMap[Op.or] : this.OperatorMap[Op.and];
const outerBinding = key === Op.not ? 'NOT ': ''; const outerBinding = key === Op.not ? 'NOT ' : '';
if (Array.isArray(value)) { if (Array.isArray(value)) {
value = value.map(item => { value = value.map(item => {
......
...@@ -166,7 +166,7 @@ class Query extends AbstractQuery { ...@@ -166,7 +166,7 @@ class Query extends AbstractQuery {
logWarnings(results) { logWarnings(results) {
return this.run('SHOW WARNINGS').then(warningResults => { return this.run('SHOW WARNINGS').then(warningResults => {
const warningMessage = `MySQL Warnings (${this.connection.uuid||'default'}): `; const warningMessage = `MySQL Warnings (${this.connection.uuid || 'default'}): `;
const messages = []; const messages = [];
for (const _warningRow of warningResults) { for (const _warningRow of warningResults) {
if (_warningRow === undefined || typeof _warningRow[Symbol.iterator] !== 'function') continue; if (_warningRow === undefined || typeof _warningRow[Symbol.iterator] !== 'function') continue;
......
...@@ -134,7 +134,7 @@ class Query extends AbstractQuery { ...@@ -134,7 +134,7 @@ class Query extends AbstractQuery {
return { return {
attribute: field, attribute: field,
collate: attribute.match(/COLLATE "(.*?)"/) ? /COLLATE "(.*?)"/.exec(attribute)[1] : undefined, collate: attribute.match(/COLLATE "(.*?)"/) ? /COLLATE "(.*?)"/.exec(attribute)[1] : undefined,
order: attribute.includes('DESC') ? 'DESC' : attribute.includes('ASC') ? 'ASC': undefined, order: attribute.includes('DESC') ? 'DESC' : attribute.includes('ASC') ? 'ASC' : undefined,
length: undefined length: undefined
}; };
}).filter(n => n !== null); }).filter(n => n !== null);
...@@ -152,9 +152,9 @@ class Query extends AbstractQuery { ...@@ -152,9 +152,9 @@ class Query extends AbstractQuery {
row.from = defParts[1]; row.from = defParts[1];
row.to = defParts[3]; row.to = defParts[3];
let i; let i;
for (i=5;i<=8;i+=3) { for (i = 5;i <= 8;i += 3) {
if (/(UPDATE|DELETE)/.test(defParts[i])) { if (/(UPDATE|DELETE)/.test(defParts[i])) {
row[`on_${defParts[i].toLowerCase()}`] = defParts[i+1]; row[`on_${defParts[i].toLowerCase()}`] = defParts[i + 1];
} }
} }
} }
......
...@@ -30,7 +30,7 @@ class Query extends AbstractQuery { ...@@ -30,7 +30,7 @@ class Query extends AbstractQuery {
if (Array.isArray(values)) { if (Array.isArray(values)) {
bindParam = {}; bindParam = {};
values.forEach((v, i) => { values.forEach((v, i) => {
bindParam[`$${i+1}`] = v; bindParam[`$${i + 1}`] = v;
}); });
sql = AbstractQuery.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0]; sql = AbstractQuery.formatBindParameters(sql, values, dialect, { skipValueReplace: true })[0];
} else { } else {
...@@ -329,7 +329,7 @@ class Query extends AbstractQuery { ...@@ -329,7 +329,7 @@ class Query extends AbstractQuery {
const constraint = constraintSql.split(' '); const constraint = constraintSql.split(' ');
if (constraint[1] === 'PRIMARY' || constraint[1] === 'FOREIGN') { if (constraint[1] === 'PRIMARY' || constraint[1] === 'FOREIGN') {
constraint[1]+= ' KEY'; constraint[1] += ' KEY';
} }
return { return {
......
...@@ -669,7 +669,7 @@ class Model { ...@@ -669,7 +669,7 @@ class Model {
} }
if (include.association.scope) { if (include.association.scope) {
include.where = include.where ? { [Op.and]: [include.where, include.association.scope] }: include.association.scope; include.where = include.where ? { [Op.and]: [include.where, include.association.scope] } : include.association.scope;
} }
if (include.limit && include.separate === undefined) { if (include.limit && include.separate === undefined) {
...@@ -2281,7 +2281,7 @@ class Model { ...@@ -2281,7 +2281,7 @@ class Model {
static findOrCreate(options) { static findOrCreate(options) {
if (!options || !options.where || arguments.length > 1) { if (!options || !options.where || arguments.length > 1) {
throw new Error( throw new Error(
'Missing where attribute in the options parameter passed to findOrCreate. '+ 'Missing where attribute in the options parameter passed to findOrCreate. ' +
'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)' 'Please note that the API has changed, and is now options only (an object with where, defaults keys, transaction etc.)'
); );
} }
......
...@@ -1160,7 +1160,7 @@ class Sequelize { ...@@ -1160,7 +1160,7 @@ class Sequelize {
// remove options from set of logged arguments if options.logging is equal to console.log // remove options from set of logged arguments if options.logging is equal to console.log
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
if (options.logging === console.log) { if (options.logging === console.log) {
args.splice(args.length-1, 1); args.splice(args.length - 1, 1);
} }
} else { } else {
options = this.options; options = this.options;
......
...@@ -44,7 +44,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => { ...@@ -44,7 +44,7 @@ describe(Support.getTestDialectTeaser('Instance'), () => {
validate: { isInt: true }, validate: { isInt: true },
set(val) { set(val) {
this.setDataValue('validateSideEffect', val); this.setDataValue('validateSideEffect', val);
this.setDataValue('validateSideAffected', val*2); this.setDataValue('validateSideAffected', val * 2);
} }
}, },
validateSideAffected: { validateSideAffected: {
......
...@@ -854,7 +854,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => { ...@@ -854,7 +854,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), () => {
it('adds a new dao to the dao manager', function() { it('adds a new dao to the dao manager', function() {
const count = this.sequelize.modelManager.all.length; const count = this.sequelize.modelManager.all.length;
this.sequelize.define('foo', { title: DataTypes.STRING }); this.sequelize.define('foo', { title: DataTypes.STRING });
expect(this.sequelize.modelManager.all.length).to.equal(count+1); expect(this.sequelize.modelManager.all.length).to.equal(count + 1);
}); });
it('adds a new dao to sequelize.models', function() { it('adds a new dao to sequelize.models', function() {
......
...@@ -162,7 +162,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => { ...@@ -162,7 +162,7 @@ describe(Support.getTestDialectTeaser('Utils'), () => {
if (Support.getTestDialect() !== 'mssql') { if (Support.getTestDialect() !== 'mssql') {
it('accepts condition object (with cast)', function() { it('accepts condition object (with cast)', function() {
const type = Support.getTestDialect() === 'mysql' ? 'unsigned': 'int'; const type = Support.getTestDialect() === 'mysql' ? 'unsigned' : 'int';
return Airplane.findAll({ return Airplane.findAll({
attributes: [ attributes: [
......
...@@ -119,7 +119,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => { ...@@ -119,7 +119,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
describe('timestamps', () => { describe('timestamps', () => {
it('follows the global timestamps true option', () => { it('follows the global timestamps true option', () => {
const User =current.define('User', {}), const User = current.define('User', {}),
Task = current.define('Task', {}); Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task1' }); User.belongsToMany(Task, { through: 'user_task1' });
...@@ -128,7 +128,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => { ...@@ -128,7 +128,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
}); });
it('allows me to override the global timestamps option', () => { it('allows me to override the global timestamps option', () => {
const User =current.define('User', {}), const User = current.define('User', {}),
Task = current.define('Task', {}); Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task2', timestamps: false }); User.belongsToMany(Task, { through: 'user_task2', timestamps: false });
...@@ -141,7 +141,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => { ...@@ -141,7 +141,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
timestamps: false timestamps: false
}); });
const User =current.define('User', {}), const User = current.define('User', {}),
Task = current.define('Task', {}); Task = current.define('Task', {});
User.belongsToMany(Task, { through: 'user_task3' }); User.belongsToMany(Task, { through: 'user_task3' });
...@@ -151,14 +151,14 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => { ...@@ -151,14 +151,14 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
}); });
describe('optimizations using bulk create, destroy and update', () => { describe('optimizations using bulk create, destroy and update', () => {
const User =current.define('User', { username: DataTypes.STRING }), const User = current.define('User', { username: DataTypes.STRING }),
Task = current.define('Task', { title: DataTypes.STRING }), Task = current.define('Task', { title: DataTypes.STRING }),
UserTasks = current.define('UserTasks', {}); UserTasks = current.define('UserTasks', {});
User.belongsToMany(Task, { through: UserTasks }); User.belongsToMany(Task, { through: UserTasks });
Task.belongsToMany(User, { through: UserTasks }); Task.belongsToMany(User, { through: UserTasks });
const user =User.build({ const user = User.build({
id: 42 id: 42
}), }),
task1 = Task.build({ task1 = Task.build({
...@@ -497,7 +497,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => { ...@@ -497,7 +497,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
describe('self-associations', () => { describe('self-associations', () => {
it('does not pair multiple self associations with different through arguments', () => { it('does not pair multiple self associations with different through arguments', () => {
const User =current.define('user', {}), const User = current.define('user', {}),
UserFollowers = current.define('userFollowers', {}), UserFollowers = current.define('userFollowers', {}),
Invite = current.define('invite', {}); Invite = current.define('invite', {});
...@@ -519,7 +519,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => { ...@@ -519,7 +519,7 @@ describe(Support.getTestDialectTeaser('belongsToMany'), () => {
}); });
it('correctly generates a foreign/other key when none are defined', () => { it('correctly generates a foreign/other key when none are defined', () => {
const User =current.define('user', {}), const User = current.define('user', {}),
UserFollowers = current.define('userFollowers', { UserFollowers = current.define('userFollowers', {
id: { id: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
......
...@@ -22,7 +22,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => { ...@@ -22,7 +22,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
}); });
describe('optimizations using bulk create, destroy and update', () => { describe('optimizations using bulk create, destroy and update', () => {
const User =current.define('User', { username: DataTypes.STRING }), const User = current.define('User', { username: DataTypes.STRING }),
Task = current.define('Task', { title: DataTypes.STRING }); Task = current.define('Task', { title: DataTypes.STRING });
User.hasMany(Task); User.hasMany(Task);
...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => { ...@@ -73,7 +73,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
}); });
describe('mixin', () => { describe('mixin', () => {
const User =current.define('User'), const User = current.define('User'),
Task = current.define('Task'); Task = current.define('Task');
it('should mixin association methods', () => { it('should mixin association methods', () => {
...@@ -137,7 +137,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => { ...@@ -137,7 +137,7 @@ describe(Support.getTestDialectTeaser('hasMany'), () => {
}); });
describe('get', () => { describe('get', () => {
const User =current.define('User', {}), const User = current.define('User', {}),
Task = current.define('Task', {}), Task = current.define('Task', {}),
idA = Math.random().toString(), idA = Math.random().toString(),
idB = Math.random().toString(), idB = Math.random().toString(),
......
...@@ -71,7 +71,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -71,7 +71,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[ [
`SELECT * FROM (SELECT [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [User] WHERE [User].[companyId] = 1 ORDER BY [last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [User] WHERE [User].[companyId] = 1 ORDER BY [last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [User] WHERE [User].[companyId] = 5 ORDER BY [last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` `SELECT * FROM (SELECT [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [User] WHERE [User].[companyId] = 5 ORDER BY [last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ') ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [User];` }) AS [User];`
}); });
...@@ -124,7 +124,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -124,7 +124,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[ [
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ') ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] ORDER BY [subquery_order_0] ASC;` }) AS [user] ORDER BY [subquery_order_0] ASC;`
}); });
...@@ -155,7 +155,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -155,7 +155,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[ [
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[last_name] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 AND [project_users].[status] = 1 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ') ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] ORDER BY [subquery_order_0] ASC;` }) AS [user] ORDER BY [subquery_order_0] ASC;`
}); });
...@@ -187,7 +187,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -187,7 +187,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[ [
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 1 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` `SELECT * FROM (SELECT [user].[id_user] AS [id], [user].[id_user] AS [subquery_order_0], [project_users].[user_id] AS [project_users.userId], [project_users].[project_id] AS [project_users.projectId] FROM [users] AS [user] INNER JOIN [project_users] AS [project_users] ON [user].[id_user] = [project_users].[user_id] AND [project_users].[project_id] = 5 WHERE [user].[age] >= 21 ORDER BY [subquery_order_0] ASC${ current.dialect.name === 'mssql' ? ', [user].[id_user]' : ''}${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ') ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] ORDER BY [subquery_order_0] ASC;` }) AS [user] ORDER BY [subquery_order_0] ASC;`
}); });
}()); }());
...@@ -273,7 +273,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -273,7 +273,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[ [
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub`, `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub`,
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub` `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: [['last_name', 'ASC']] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ') ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id];` }) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id];`
}); });
...@@ -337,7 +337,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -337,7 +337,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
[ [
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`, `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 1 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`,
`SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub` `SELECT * FROM (SELECT [id_user] AS [id], [email], [first_name] AS [firstName], [last_name] AS [lastName] FROM [users] AS [user] WHERE [user].[companyId] = 5 ORDER BY [user].[last_name] ASC${sql.addLimitAndOffset({ limit: 3, order: ['last_name', 'ASC'] })}) AS sub`
].join(current.dialect.supports['UNION ALL'] ?' UNION ALL ' : ' UNION ') ].join(current.dialect.supports['UNION ALL'] ? ' UNION ALL ' : ' UNION ')
}) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id] LEFT OUTER JOIN [comment] AS [POSTS->COMMENTS] ON [POSTS].[id] = [POSTS->COMMENTS].[post_id];` }) AS [user] LEFT OUTER JOIN [post] AS [POSTS] ON [user].[id] = [POSTS].[user_id] LEFT OUTER JOIN [comment] AS [POSTS->COMMENTS] ON [POSTS].[id] = [POSTS->COMMENTS].[post_id];`
}); });
})(); })();
......
...@@ -20,7 +20,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => { ...@@ -20,7 +20,7 @@ describe(Support.getTestDialectTeaser('SQL'), () => {
options = undefined; options = undefined;
} }
it(util.inspect(params, { depth: 10 })+(options && `, ${util.inspect(options)}` || ''), () => { it(util.inspect(params, { depth: 10 }) + (options && `, ${util.inspect(options)}` || ''), () => {
const sqlOrError = _.attempt(sql.whereQuery.bind(sql), params, options); const sqlOrError = _.attempt(sql.whereQuery.bind(sql), params, options);
return expectsql(sqlOrError, expectation); return expectsql(sqlOrError, expectation);
}); });
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!