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 b2bc9a26
authored
Jan 04, 2014
by
Martin Blumenstingl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for max(String) and min(String) and support BIGINT as well.
1 parent
c80079ae
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
lib/query-interface.js
test/dao-factory.test.js
lib/query-interface.js
View file @
b2bc9a2
...
@@ -689,6 +689,7 @@ module.exports = (function() {
...
@@ -689,6 +689,7 @@ module.exports = (function() {
if
(
options
&&
options
.
dataType
)
{
if
(
options
&&
options
.
dataType
)
{
switch
(
options
.
dataType
)
{
switch
(
options
.
dataType
)
{
case
DataTypes
.
INTEGER
:
case
DataTypes
.
INTEGER
:
case
DataTypes
.
BIGINT
:
result
=
parseInt
(
result
,
10
);
result
=
parseInt
(
result
,
10
);
break
;
break
;
case
DataTypes
.
FLOAT
:
case
DataTypes
.
FLOAT
:
...
@@ -697,6 +698,9 @@ module.exports = (function() {
...
@@ -697,6 +698,9 @@ module.exports = (function() {
case
DataTypes
.
DATE
:
case
DataTypes
.
DATE
:
result
=
new
Date
(
result
+
'Z'
);
result
=
new
Date
(
result
+
'Z'
);
break
;
break
;
case
DataTypes
.
STRING
:
// Nothing to do, result is already a string.
break
;
}
}
}
}
...
...
test/dao-factory.test.js
View file @
b2bc9a2
...
@@ -1037,6 +1037,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1037,6 +1037,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
})
it
(
"should allow strings in min"
,
function
(
done
)
{
var
self
=
this
this
.
User
.
bulkCreate
([{
username
:
'bbb'
},
{
username
:
'yyy'
}]).
success
(
function
(){
self
.
User
.
min
(
'username'
).
success
(
function
(
min
){
expect
(
min
).
to
.
equal
(
'bbb'
)
done
()
})
})
})
it
(
"should allow dates in min"
,
function
(
done
){
it
(
"should allow dates in min"
,
function
(
done
){
var
self
=
this
var
self
=
this
this
.
User
.
bulkCreate
([{
theDate
:
new
Date
(
2000
,
01
,
01
)},
{
theDate
:
new
Date
(
1990
,
01
,
01
)}]).
success
(
function
(){
this
.
User
.
bulkCreate
([{
theDate
:
new
Date
(
2000
,
01
,
01
)},
{
theDate
:
new
Date
(
1990
,
01
,
01
)}]).
success
(
function
(){
...
@@ -1129,6 +1139,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
...
@@ -1129,6 +1139,16 @@ describe(Support.getTestDialectTeaser("DAOFactory"), function () {
})
})
})
})
it
(
"should allow strings in max"
,
function
(
done
)
{
var
self
=
this
this
.
User
.
bulkCreate
([{
username
:
'aaa'
},
{
username
:
'zzz'
}]).
success
(
function
(){
self
.
User
.
max
(
'username'
).
success
(
function
(
max
){
expect
(
max
).
to
.
equal
(
'zzz'
)
done
()
})
})
})
it
(
'allows sql logging'
,
function
(
done
)
{
it
(
'allows sql logging'
,
function
(
done
)
{
this
.
UserWithAge
.
max
(
'age'
).
on
(
'sql'
,
function
(
sql
)
{
this
.
UserWithAge
.
max
(
'age'
).
on
(
'sql'
,
function
(
sql
)
{
expect
(
sql
).
to
.
exist
expect
(
sql
).
to
.
exist
...
...
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