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 8640abe3
authored
Mar 02, 2016
by
Sushant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added new error class EmptyResultError for rejectOnEmpty
1 parent
163651b2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
3 deletions
lib/errors.js
lib/sequelize.js
test/integration/model/find.test.js
lib/errors.js
View file @
8640abe
...
@@ -299,3 +299,15 @@ error.InstanceError = function (message) {
...
@@ -299,3 +299,15 @@ error.InstanceError = function (message) {
this
.
message
=
message
;
this
.
message
=
message
;
};
};
util
.
inherits
(
error
.
InstanceError
,
error
.
BaseError
);
util
.
inherits
(
error
.
InstanceError
,
error
.
BaseError
);
/**
* Thrown when a record was not found, Usually used with kenophobic mode (see message for details)
* @extends BaseError
* @constructor
*/
error
.
EmptyResultError
=
function
(
message
)
{
error
.
BaseError
.
apply
(
this
,
arguments
);
this
.
name
=
'SequelizeEmptyResultError'
;
this
.
message
=
message
;
};
util
.
inherits
(
error
.
EmptyResultError
,
error
.
BaseError
);
lib/sequelize.js
View file @
8640abe
...
@@ -441,6 +441,13 @@ Sequelize.prototype.ConnectionTimedOutError = Sequelize.ConnectionTimedOutError
...
@@ -441,6 +441,13 @@ Sequelize.prototype.ConnectionTimedOutError = Sequelize.ConnectionTimedOutError
Sequelize
.
prototype
.
InstanceError
=
Sequelize
.
InstanceError
=
Sequelize
.
prototype
.
InstanceError
=
Sequelize
.
InstanceError
=
sequelizeErrors
.
InstanceError
;
sequelizeErrors
.
InstanceError
;
/**
* Thrown when a record was not found, Usually used with kenophobic mode (see message for details)
* @see {Errors#RecordNotFoundError}
*/
Sequelize
.
prototype
.
EmptyResultError
=
Sequelize
.
EmptyResultError
=
sequelizeErrors
.
EmptyResultError
;
Sequelize
.
prototype
.
refreshTypes
=
function
()
{
Sequelize
.
prototype
.
refreshTypes
=
function
()
{
this
.
connectionManager
.
refreshTypeParser
(
DataTypes
);
this
.
connectionManager
.
refreshTypeParser
(
DataTypes
);
...
...
test/integration/model/find.test.js
View file @
8640abe
...
@@ -944,13 +944,13 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -944,13 +944,13 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}
}
},
{
},
{
kenophobic
:
true
kenophobic
:
true
})).
to
.
eventually
.
be
.
rejectedWith
(
Sequelize
.
RecordNotFound
Error
);
})).
to
.
eventually
.
be
.
rejectedWith
(
Sequelize
.
EmptyResult
Error
);
});
});
it
(
'throws error when record not found by findById'
,
function
()
{
it
(
'throws error when record not found by findById'
,
function
()
{
return
expect
(
this
.
User
.
findById
(
4732322332323333232344334354234
,
{
return
expect
(
this
.
User
.
findById
(
4732322332323333232344334354234
,
{
kenophobic
:
true
kenophobic
:
true
})).
to
.
eventually
.
be
.
rejectedWith
(
Sequelize
.
RecordNotFound
Error
);
})).
to
.
eventually
.
be
.
rejectedWith
(
Sequelize
.
EmptyResult
Error
);
});
});
it
(
'throws error when record not found by find'
,
function
()
{
it
(
'throws error when record not found by find'
,
function
()
{
...
@@ -960,7 +960,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
...
@@ -960,7 +960,7 @@ describe(Support.getTestDialectTeaser('Model'), function() {
}
}
},
{
},
{
kenophobic
:
true
kenophobic
:
true
})).
to
.
eventually
.
be
.
rejectedWith
(
Sequelize
.
RecordNotFound
Error
);
})).
to
.
eventually
.
be
.
rejectedWith
(
Sequelize
.
EmptyResult
Error
);
});
});
});
});
...
...
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