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 4e6d070b
authored
Jan 05, 2014
by
Martin Blumenstingl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle more data-types in min() and max() that take optional arguments.
1 parent
23a727f2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
20 deletions
lib/query-interface.js
test/data-types.test.js
lib/query-interface.js
View file @
4e6d070
...
...
@@ -688,25 +688,15 @@ module.exports = (function() {
if
(
options
&&
options
.
dataType
)
{
var
dataType
=
options
.
dataType
;
if
(
dataType
instanceof
DataTypes
.
DECIMAL
)
{
dataType
=
DataTypes
.
DECIMAL
;
}
switch
(
dataType
)
{
case
DataTypes
.
INTEGER
:
case
DataTypes
.
BIGINT
:
result
=
parseInt
(
result
,
10
);
break
;
case
DataTypes
.
FLOAT
:
case
DataTypes
.
DECIMAL
:
result
=
parseFloat
(
result
);
break
;
case
DataTypes
.
DATE
:
result
=
new
Date
(
result
+
'Z'
);
break
;
case
DataTypes
.
STRING
:
// Nothing to do, result is already a string.
break
;
if
(
dataType
instanceof
DataTypes
.
DECIMAL
||
dataType
instanceof
DataTypes
.
FLOAT
)
{
result
=
parseFloat
(
result
);
}
else
if
(
dataType
===
DataTypes
.
INTEGER
||
dataType
instanceof
DataTypes
.
BIGINT
)
{
result
=
parseInt
(
result
,
10
);
}
else
if
(
dataType
===
DataTypes
.
DATE
)
{
result
=
new
Date
(
result
+
'Z'
);
}
else
if
(
dataType
===
DataTypes
.
STRING
)
{
// Nothing to do, result is already a string.
}
}
...
...
test/data-types.test.js
View file @
4e6d070
...
...
@@ -6,8 +6,43 @@ var chai = require('chai')
chai
.
Assertion
.
includeStack
=
true
describe
(
Support
.
getTestDialectTeaser
(
'DataTypes'
),
function
()
{
it
(
'should return DECIMAL for the default decimal type'
,
function
(
done
)
{
expect
(
Sequelize
.
DECIMAL
.
toString
()).
to
.
equal
(
'DECIMAL'
)
it
(
'should return false when comparing DECIMAL and DECIMAL(10,2)'
,
function
(
done
)
{
expect
(
Sequelize
.
DECIMAL
).
to
.
not
.
equal
(
Sequelize
.
DECIMAL
(
10
,
2
))
done
()
})
it
(
'DECIMAL(10,2) should be an instance of DECIMAL'
,
function
(
done
)
{
expect
(
Sequelize
.
DECIMAL
(
10
,
2
)).
to
.
be
.
an
.
instanceof
(
Sequelize
.
DECIMAL
)
done
()
})
it
(
'should return false when comparing FLOAT and FLOAT(11)'
,
function
(
done
)
{
expect
(
Sequelize
.
FLOAT
).
to
.
not
.
equal
(
Sequelize
.
FLOAT
(
11
))
done
()
})
it
(
'FLOAT(11) should be an instance of FLOAT'
,
function
(
done
)
{
expect
(
Sequelize
.
FLOAT
(
11
)).
to
.
be
.
an
.
instanceof
(
Sequelize
.
FLOAT
)
done
()
})
it
(
'should return false when comparing STRING and STRING(4096)'
,
function
(
done
)
{
expect
(
Sequelize
.
STRING
).
to
.
not
.
equal
(
Sequelize
.
STRING
(
4096
))
done
()
})
it
(
'STRING(4096) should be an instance of STRING'
,
function
(
done
)
{
expect
(
Sequelize
.
STRING
(
4096
)).
to
.
be
.
an
.
instanceof
(
Sequelize
.
STRING
)
done
()
})
it
(
'should return false when comparing BIGINT and BIGINT(11)'
,
function
(
done
)
{
expect
(
Sequelize
.
BIGINT
).
to
.
not
.
equal
(
Sequelize
.
BIGINT
(
11
))
done
()
})
it
(
'BIGINT(11) should be an instance of BIGINT'
,
function
(
done
)
{
expect
(
Sequelize
.
BIGINT
(
11
)).
to
.
be
.
an
.
instanceof
(
Sequelize
.
BIGINT
)
done
()
})
...
...
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