Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 58573c19
authored
Aug 05, 2016
by
Juan Hoyos
Committed by
Jan Aagaard Meier
Aug 05, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create concurrent indexes at the end to avoid postgresql deadlocks. (#5810)
Also, fixed mssql tests
1 parent
56c3baf5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
3 deletions
lib/model.js
test/integration/model.test.js
lib/model.js
View file @
58573c1
...
...
@@ -923,7 +923,17 @@ class Model {
// Assign an auto-generated name to indexes which are not named by the user
this
.
options
.
indexes
=
this
.
QueryInterface
.
nameIndexes
(
this
.
options
.
indexes
,
this
.
tableName
);
indexes
=
_
.
filter
(
this
.
options
.
indexes
,
item1
=>
!
_
.
some
(
indexes
,
item2
=>
item1
.
name
===
item2
.
name
));
indexes
=
_
.
filter
(
this
.
options
.
indexes
,
(
item1
)
=>
(
!
_
.
some
(
indexes
,
item2
=>
item1
.
name
===
item2
.
name
)
)).
sort
((
index1
,
index2
)
=>
{
if
(
this
.
sequelize
.
options
.
dialect
===
'postgres'
)
{
// move concurrent indexes to the bottom to avoid weird deadlocks
if
(
index1
.
concurrently
===
true
)
return
1
;
if
(
index2
.
concurrently
===
true
)
return
-
1
;
}
return
0
;
});
return
Promise
.
map
(
indexes
,
index
=>
this
.
QueryInterface
.
addIndex
(
this
.
getTableName
(
options
),
...
...
test/integration/model.test.js
View file @
58573c1
...
...
@@ -377,12 +377,18 @@ describe(Support.getTestDialectTeaser('Model'), function() {
fields
:
[
'fieldC'
],
concurrently
:
true
});
indices
.
push
({
type
:
'FULLTEXT'
,
fields
:
[
'fieldD'
]
});
}
var
Model
=
this
.
sequelize
.
define
(
'model'
,
{
fieldA
:
Sequelize
.
STRING
,
fieldB
:
Sequelize
.
INTEGER
,
fieldC
:
Sequelize
.
STRING
fieldC
:
Sequelize
.
STRING
,
fieldD
:
Sequelize
.
STRING
},
{
indexes
:
indices
,
engine
:
'MyISAM'
...
...
@@ -393,7 +399,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}).
then
(
function
()
{
return
this
.
sequelize
.
queryInterface
.
showIndex
(
Model
.
tableName
);
}).
spread
(
function
()
{
var
primary
,
idx1
,
idx2
;
var
primary
,
idx1
,
idx2
,
idx3
;
if
(
dialect
===
'sqlite'
)
{
// PRAGMA index_info does not return the primary index
...
...
@@ -420,6 +426,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
primary
=
arguments
[
2
];
idx1
=
arguments
[
0
];
idx2
=
arguments
[
1
];
idx3
=
arguments
[
2
];
expect
(
idx1
.
fields
).
to
.
deep
.
equal
([
{
attribute
:
'fieldB'
,
length
:
undefined
,
order
:
undefined
,
collate
:
undefined
},
...
...
@@ -429,6 +436,10 @@ describe(Support.getTestDialectTeaser('Model'), function() {
expect
(
idx2
.
fields
).
to
.
deep
.
equal
([
{
attribute
:
'fieldC'
,
length
:
undefined
,
order
:
undefined
,
collate
:
undefined
}
]);
expect
(
idx3
.
fields
).
to
.
deep
.
equal
([
{
attribute
:
'fieldD'
,
length
:
undefined
,
order
:
undefined
,
collate
:
undefined
}
]);
}
else
{
// And finally mysql returns the primary first, and then the rest in the order they were defined
primary
=
arguments
[
0
];
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment