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 4d6cce82
authored
Feb 24, 2015
by
Dr. Evil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code formatting
1 parent
4619a544
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
32 deletions
lib/dialects/postgres/query.js
test/integration/dialects/postgres/dao.test.js
lib/dialects/postgres/query.js
View file @
4d6cce8
...
@@ -9,31 +9,35 @@ var Utils = require('../../utils')
...
@@ -9,31 +9,35 @@ var Utils = require('../../utils')
,
Promise
=
require
(
'../../promise'
)
,
Promise
=
require
(
'../../promise'
)
,
sequelizeErrors
=
require
(
'../../errors.js'
);
,
sequelizeErrors
=
require
(
'../../errors.js'
);
var
parseDialectSpecificFields
=
{
var
parseDialectSpecificFields
,
// Parses hstore fields if the model has any hstore fields.
dialectSpecificTypes
;
// This cannot be done in the 'pg' lib because hstore is a UDT.
hstore
:
function
(
value
,
options
)
{
parseDialectSpecificFields
=
{
if
(
value
===
null
)
return
null
;
// Parses hstore fields if the model has any hstore fields.
// This cannot be done in the 'pg' lib because hstore is a UDT.
return
DataTypes
.
ARRAY
.
is
(
options
.
dataType
,
DataTypes
.
HSTORE
)
?
hstore
:
function
(
value
,
options
)
{
Utils
.
_
.
map
(
if
(
value
===
null
)
return
null
;
JSON
.
parse
(
'['
+
value
.
substring
(
1
,
value
.
length
-
1
)
+
']'
),
function
(
v
)
{
return
hstore
.
parse
(
v
);
return
DataTypes
.
ARRAY
.
is
(
options
.
dataType
,
DataTypes
.
HSTORE
)
?
})
:
hstore
.
parse
(
value
);
Utils
.
_
.
map
(
},
JSON
.
parse
(
'['
+
value
.
substring
(
1
,
value
.
length
-
1
)
+
']'
),
function
(
v
)
{
range
:
function
(
value
,
options
)
{
return
hstore
.
parse
(
v
);
if
(
value
===
null
)
return
null
;
})
:
hstore
.
parse
(
value
);
},
return
DataTypes
.
ARRAY
.
is
(
options
.
dataType
,
DataTypes
.
RANGE
)
?
range
:
function
(
value
,
options
)
{
Utils
.
_
.
map
(
if
(
value
===
null
)
return
null
;
JSON
.
parse
(
'['
+
value
.
substring
(
1
,
value
.
length
-
1
)
+
']'
),
function
(
v
)
{
return
DataTypes
.
ARRAY
.
is
(
options
.
dataType
,
DataTypes
.
RANGE
)
?
return
range
.
parse
(
v
,
options
.
dataType
.
type
);
Utils
.
_
.
map
(
})
:
JSON
.
parse
(
'['
+
value
.
substring
(
1
,
value
.
length
-
1
)
+
']'
),
range
.
parse
(
value
,
options
.
dataType
);
function
(
v
)
{
}
return
range
.
parse
(
v
,
options
.
dataType
.
type
);
},
})
:
dialectSpecificTypes
=
Utils
.
_
.
keys
(
parseDialectSpecificFields
);
range
.
parse
(
value
,
options
.
dataType
);
}
};
dialectSpecificTypes
=
Utils
.
_
.
keys
(
parseDialectSpecificFields
);
function
dialectSpecificFieldDatatypeMap
(
options
,
prefix
)
{
function
dialectSpecificFieldDatatypeMap
(
options
,
prefix
)
{
if
(
!
Utils
.
_
.
isArray
(
options
.
types
))
if
(
!
Utils
.
_
.
isArray
(
options
.
types
))
...
...
test/integration/dialects/postgres/dao.test.js
View file @
4d6cce8
...
@@ -744,8 +744,8 @@ if (dialect.match(/^postgres/)) {
...
@@ -744,8 +744,8 @@ if (dialect.match(/^postgres/)) {
});
});
it
(
'should update range correctly'
,
function
()
{
it
(
'should update range correctly'
,
function
()
{
var
User
=
this
.
User
,
var
User
=
this
.
User
period
=
[
new
Date
(
2015
,
0
,
1
),
new
Date
(
2015
,
11
,
31
)];
,
period
=
[
new
Date
(
2015
,
0
,
1
),
new
Date
(
2015
,
11
,
31
)];
return
User
.
create
({
username
:
'user'
,
email
:
[
'foo@bar.com'
],
course_period
:
period
}).
then
(
function
(
newUser
)
{
return
User
.
create
({
username
:
'user'
,
email
:
[
'foo@bar.com'
],
course_period
:
period
}).
then
(
function
(
newUser
)
{
// Check to see if the default value for a range field works
// Check to see if the default value for a range field works
...
@@ -775,8 +775,8 @@ if (dialect.match(/^postgres/)) {
...
@@ -775,8 +775,8 @@ if (dialect.match(/^postgres/)) {
});
});
it
(
'should update range correctly and return the affected rows'
,
function
()
{
it
(
'should update range correctly and return the affected rows'
,
function
()
{
var
User
=
this
.
User
,
var
User
=
this
.
User
period
=
[
new
Date
(
2015
,
1
,
1
),
new
Date
(
2015
,
10
,
30
)];
,
period
=
[
new
Date
(
2015
,
1
,
1
),
new
Date
(
2015
,
10
,
30
)];
return
User
.
create
({
return
User
.
create
({
username
:
'user'
,
username
:
'user'
,
...
@@ -863,9 +863,9 @@ if (dialect.match(/^postgres/)) {
...
@@ -863,9 +863,9 @@ if (dialect.match(/^postgres/)) {
});
});
it
(
'should read range correctly from included models as well'
,
function
()
{
it
(
'should read range correctly from included models as well'
,
function
()
{
var
self
=
this
,
var
self
=
this
period
=
[
new
Date
(
2016
,
0
,
1
),
new
Date
(
2016
,
11
,
31
)],
,
period
=
[
new
Date
(
2016
,
0
,
1
),
new
Date
(
2016
,
11
,
31
)]
HolidayDate
=
this
.
sequelize
.
define
(
'holidayDate'
,
{
,
HolidayDate
=
this
.
sequelize
.
define
(
'holidayDate'
,
{
period
:
DataTypes
.
RANGE
(
DataTypes
.
DATE
)
period
:
DataTypes
.
RANGE
(
DataTypes
.
DATE
)
});
});
...
...
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