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 702e3659
authored
Jul 17, 2018
by
Sushant
Committed by
GitHub
Jul 17, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ci(postgres): remove extra beforeEach (#9681)
1 parent
eda64954
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
21 deletions
lib/transaction.js
test/integration/dialects/postgres/error.test.js
lib/transaction.js
View file @
702e365
'use strict'
;
'use strict'
;
const
_
=
require
(
'lodash'
);
const
_
=
require
(
'lodash'
);
const
Utils
=
require
(
'./utils
'
);
const
Promise
=
require
(
'./promise
'
);
/**
/**
* The transaction object is used to identify a running transaction. It is created by calling `Sequelize.transaction()`.
* The transaction object is used to identify a running transaction. It is created by calling `Sequelize.transaction()`.
...
@@ -57,7 +57,7 @@ class Transaction {
...
@@ -57,7 +57,7 @@ class Transaction {
commit
()
{
commit
()
{
if
(
this
.
finished
)
{
if
(
this
.
finished
)
{
return
Utils
.
Promise
.
reject
(
new
Error
(
'Transaction cannot be committed because it has been finished with state: '
+
this
.
finished
));
return
Promise
.
reject
(
new
Error
(
'Transaction cannot be committed because it has been finished with state: '
+
this
.
finished
));
}
}
this
.
_clearCls
();
this
.
_clearCls
();
...
@@ -73,9 +73,9 @@ class Transaction {
...
@@ -73,9 +73,9 @@ class Transaction {
}
}
return
null
;
return
null
;
}).
tap
(
}).
tap
(
()
=>
Utils
.
Promise
.
each
(
()
=>
Promise
.
each
(
this
.
_afterCommitHooks
,
this
.
_afterCommitHooks
,
hook
=>
Utils
.
Promise
.
resolve
(
hook
.
apply
(
this
,
[
this
])))
hook
=>
Promise
.
resolve
(
hook
.
apply
(
this
,
[
this
])))
);
);
}
}
...
@@ -87,7 +87,7 @@ class Transaction {
...
@@ -87,7 +87,7 @@ class Transaction {
rollback
()
{
rollback
()
{
if
(
this
.
finished
)
{
if
(
this
.
finished
)
{
return
Utils
.
Promise
.
reject
(
new
Error
(
'Transaction cannot be rolled back because it has been finished with state: '
+
this
.
finished
));
return
Promise
.
reject
(
new
Error
(
'Transaction cannot be rolled back because it has been finished with state: '
+
this
.
finished
));
}
}
this
.
_clearCls
();
this
.
_clearCls
();
...
@@ -112,7 +112,7 @@ class Transaction {
...
@@ -112,7 +112,7 @@ class Transaction {
}
}
if
(
this
.
parent
)
{
if
(
this
.
parent
)
{
connectionPromise
=
Utils
.
Promise
.
resolve
(
this
.
parent
.
connection
);
connectionPromise
=
Promise
.
resolve
(
this
.
parent
.
connection
);
}
else
{
}
else
{
const
acquireOptions
=
{
uuid
:
this
.
id
};
const
acquireOptions
=
{
uuid
:
this
.
id
};
if
(
this
.
options
.
readOnly
)
{
if
(
this
.
options
.
readOnly
)
{
...
...
test/integration/dialects/postgres/error.test.js
View file @
702e365
...
@@ -9,22 +9,22 @@ const chai = require('chai'),
...
@@ -9,22 +9,22 @@ const chai = require('chai'),
_
=
require
(
'lodash'
);
_
=
require
(
'lodash'
);
if
(
dialect
.
match
(
/^postgres/
))
{
if
(
dialect
.
match
(
/^postgres/
))
{
const
constraintName
=
'overlap_period'
;
beforeEach
(
function
()
{
const
self
=
this
;
this
.
Booking
=
self
.
sequelize
.
define
(
'Booking'
,
{
roomNo
:
DataTypes
.
INTEGER
,
period
:
DataTypes
.
RANGE
(
DataTypes
.
DATE
)
});
return
self
.
Booking
.
sync
({
force
:
true
})
.
then
(()
=>
{
return
self
.
sequelize
.
query
(
'ALTER TABLE "'
+
self
.
Booking
.
tableName
+
'" ADD CONSTRAINT '
+
constraintName
+
' EXCLUDE USING gist ("roomNo" WITH =, period WITH &&)'
);
});
});
describe
(
'[POSTGRES Specific] ExclusionConstraintError'
,
()
=>
{
describe
(
'[POSTGRES Specific] ExclusionConstraintError'
,
()
=>
{
const
constraintName
=
'overlap_period'
;
beforeEach
(
function
()
{
const
self
=
this
;
this
.
Booking
=
self
.
sequelize
.
define
(
'Booking'
,
{
roomNo
:
DataTypes
.
INTEGER
,
period
:
DataTypes
.
RANGE
(
DataTypes
.
DATE
)
});
return
self
.
Booking
.
sync
({
force
:
true
})
.
then
(()
=>
{
return
self
.
sequelize
.
query
(
`ALTER TABLE "
${
self
.
Booking
.
tableName
}
" ADD CONSTRAINT
${
constraintName
}
EXCLUDE USING gist ("roomNo" WITH =, period WITH &&)`
);
});
});
it
(
'should contain error specific properties'
,
()
=>
{
it
(
'should contain error specific properties'
,
()
=>
{
const
errDetails
=
{
const
errDetails
=
{
...
...
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