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 b9d42fc9
authored
Apr 12, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(model): findOrCreate should not include postgres exception catcher in result, closes #3246
1 parent
7a73493f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
10 deletions
lib/dialects/postgres/query.js
test/integration/model/create.test.js
test/support.js
lib/dialects/postgres/query.js
View file @
b9d42fc
...
...
@@ -135,11 +135,18 @@ module.exports = (function() {
return
results
;
}
if
(
rows
[
0
]
&&
rows
[
0
].
sequelize_caught_exception
)
{
if
(
rows
[
0
]
&&
rows
[
0
].
sequelize_caught_exception
!==
undefined
)
{
if
(
rows
[
0
].
sequelize_caught_exception
!==
null
)
{
throw
new
self
.
formatError
({
code
:
'23505'
,
detail
:
rows
[
0
].
sequelize_caught_exception
});
}
else
{
rows
=
rows
.
map
(
function
(
row
)
{
delete
row
.
sequelize_caught_exception
;
return
row
;
});
}
}
if
(
self
.
isShowIndexesQuery
())
{
...
...
test/integration/model/create.test.js
View file @
b9d42fc
...
...
@@ -89,19 +89,14 @@ describe(Support.getTestDialectTeaser('Model'), function() {
username
:
'gottlieb'
});
}).
then
(
function
()
{
return
User
.
findOrCreate
({
return
expect
(
User
.
findOrCreate
({
where
:
{
objectId
:
'asdasdasd'
},
defaults
:
{
username
:
'gottlieb'
}
}).
then
(
function
()
{
throw
new
Error
(
'I should have been rejected'
);
}).
catch
(
function
(
err
)
{
expect
(
err
instanceof
Sequelize
.
UniqueConstraintError
).
to
.
be
.
ok
;
expect
(
err
.
fields
).
to
.
be
.
ok
;
});
})).
to
.
eventually
.
be
.
rejectedWith
(
Sequelize
.
UniqueConstraintError
);
});
});
...
...
@@ -266,6 +261,28 @@ describe(Support.getTestDialectTeaser('Model'), function() {
});
});
it
(
'does not include exception catcher in response'
,
function
()
{
var
self
=
this
,
data
=
{
username
:
'Username'
,
data
:
'ThisIsData'
};
return
self
.
User
.
findOrCreate
({
where
:
data
,
defaults
:
{}
}).
spread
(
function
(
user
,
created
)
{
expect
(
user
.
dataValues
.
sequelize_caught_exception
).
to
.
be
.
undefined
;
}).
then
(
function
()
{
return
self
.
User
.
findOrCreate
({
where
:
data
,
defaults
:
{}
}).
spread
(
function
(
user
,
created
)
{
expect
(
user
.
dataValues
.
sequelize_caught_exception
).
to
.
be
.
undefined
;
});
});
});
it
(
'creates new instance with default value.'
,
function
()
{
var
data
=
{
username
:
'Username'
...
...
test/support.js
View file @
b9d42fc
...
...
@@ -7,8 +7,9 @@ var fs = require('fs')
,
DataTypes
=
require
(
__dirname
+
'/../lib/data-types'
)
,
Config
=
require
(
__dirname
+
'/config/config'
)
,
chai
=
require
(
'chai'
)
,
expect
=
chai
.
expect
,
chaiAsPromised
=
require
(
'chai-as-promised'
);
,
expect
=
chai
.
expect
;
chai
.
use
(
require
(
'chai-as-promised'
));
// Make sure errors get thrown when testing
Sequelize
.
Promise
.
onPossiblyUnhandledRejection
(
function
(
e
,
promise
)
{
...
...
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