regressions.test.js
3.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
'use strict';
const chai = require('chai'),
expect = chai.expect,
Support = require('../../support'),
Sequelize = Support.Sequelize,
Op = Sequelize.Op,
dialect = Support.getTestDialect();
if (dialect.match(/^mssql/)) {
describe('[MSSQL Specific] Regressions', () => {
it('does not duplicate columns in ORDER BY statement, #9008', function() {
const LoginLog = this.sequelize.define('LoginLog', {
ID: {
field: 'id',
type: Sequelize.INTEGER,
primaryKey: true,
autoIncrement: true
},
UserID: {
field: 'userid',
type: Sequelize.UUID,
allowNull: false
}
});
const User = this.sequelize.define('User', {
UserID: {
field: 'userid',
type: Sequelize.UUID,
defaultValue: Sequelize.UUIDV4,
primaryKey: true
},
UserName: {
field: 'username',
type: Sequelize.STRING(50),
allowNull: false
}
});
LoginLog.belongsTo(User, {
foreignKey: 'UserID'
});
User.hasMany(LoginLog, {
foreignKey: 'UserID'
});
return this.sequelize.sync({ force: true })
.then(() => User.bulkCreate([
{ UserName: 'Vayom' },
{ UserName: 'Shaktimaan' },
{ UserName: 'Nikita' },
{ UserName: 'Aryamaan' }
], { returning: true }))
.then(([vyom, shakti, nikita, arya]) => {
return Sequelize.Promise.all([
vyom.createLoginLog(),
shakti.createLoginLog(),
nikita.createLoginLog(),
arya.createLoginLog()
]);
}).then(() => {
return LoginLog.findAll({
include: [
{
model: User,
where: {
UserName: {
[Op.like]: '%maan%'
}
}
}
],
order: [[User, 'UserName', 'DESC']],
offset: 0,
limit: 10
});
}).then(logs => {
expect(logs).to.have.length(2);
expect(logs[0].User.get('UserName')).to.equal('Shaktimaan');
expect(logs[1].User.get('UserName')).to.equal('Aryamaan');
});
});
});
it('sets the varchar(max) length correctly on describeTable', function() {
const Users = this.sequelize.define('_Users', {
username: Sequelize.STRING('MAX')
}, { freezeTableName: true });
return Users.sync({ force: true }).then(() => {
return this.sequelize.getQueryInterface().describeTable('_Users').then(metadata => {
const username = metadata.username;
expect(username.type).to.include('(MAX)');
});
});
});
it('sets the char(10) length correctly on describeTable', function() {
const Users = this.sequelize.define('_Users', {
username: Sequelize.CHAR(10)
}, { freezeTableName: true });
return Users.sync({ force: true }).then(() => {
return this.sequelize.getQueryInterface().describeTable('_Users').then(metadata => {
const username = metadata.username;
expect(username.type).to.include('(10)');
});
});
});
it('saves value bigger than 2147483647, #11245', function() {
const BigIntTable = this.sequelize.define('BigIntTable', {
business_id: {
type: Sequelize.BIGINT,
allowNull: false
}
}, {
freezeTableName: true
});
const bigIntValue = 2147483648;
return BigIntTable.sync({ force: true })
.then(() => {
return BigIntTable.create({
business_id: bigIntValue
});
})
.then(() => BigIntTable.findOne())
.then(record => {
expect(Number(record.business_id)).to.equals(bigIntValue);
});
});
}