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 b8e24d0c
authored
Dec 16, 2015
by
Mick Hansen
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5044 from sushantdhiman/fix-4307
Postgres named timezone issue
2 parents
76a876f7
061793bd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
2 deletions
changelog.md
lib/dialects/postgres/connection-manager.js
test/integration/dialects/postgres/connection-manager.test.js
changelog.md
View file @
b8e24d0
# Future
# Future
-
[
FIXED
]
Postgres issue when using named timezone
[
#4307
](
https://github.com/sequelize/sequelize/issues/4307
)
-
[
ADDED
]
Improve support for pg range type to handle unbound ranges, +/-infinity bounds and empty ranges
-
[
ADDED
]
Improve support for pg range type to handle unbound ranges, +/-infinity bounds and empty ranges
-
[
FIXED
]
Add support for Babel/ES6 imports
[
#4881
](
https://github.com/sequelize/sequelize/issues/4881
)
-
[
FIXED
]
Add support for Babel/ES6 imports
[
#4881
](
https://github.com/sequelize/sequelize/issues/4881
)
# 3.14.2
# 3.14.2
...
...
lib/dialects/postgres/connection-manager.js
View file @
b8e24d0
...
@@ -6,7 +6,8 @@ var AbstractConnectionManager = require('../abstract/connection-manager')
...
@@ -6,7 +6,8 @@ var AbstractConnectionManager = require('../abstract/connection-manager')
,
Promise
=
require
(
'../../promise'
)
,
Promise
=
require
(
'../../promise'
)
,
sequelizeErrors
=
require
(
'../../errors'
)
,
sequelizeErrors
=
require
(
'../../errors'
)
,
semver
=
require
(
'semver'
)
,
semver
=
require
(
'semver'
)
,
dataTypes
=
require
(
'../../data-types'
);
,
dataTypes
=
require
(
'../../data-types'
)
,
moment
=
require
(
'moment-timezone'
);
ConnectionManager
=
function
(
dialect
,
sequelize
)
{
ConnectionManager
=
function
(
dialect
,
sequelize
)
{
AbstractConnectionManager
.
call
(
this
,
dialect
,
sequelize
);
AbstractConnectionManager
.
call
(
this
,
dialect
,
sequelize
);
...
@@ -129,7 +130,12 @@ ConnectionManager.prototype.connect = function(config) {
...
@@ -129,7 +130,12 @@ ConnectionManager.prototype.connect = function(config) {
}
}
if
(
!
self
.
sequelize
.
config
.
keepDefaultTimezone
)
{
if
(
!
self
.
sequelize
.
config
.
keepDefaultTimezone
)
{
query
+=
'SET client_min_messages TO warning; SET TIME ZONE INTERVAL \''
+
self
.
sequelize
.
options
.
timezone
+
'\' HOUR TO MINUTE;'
;
var
isZone
=
!!
moment
.
tz
.
zone
(
self
.
sequelize
.
options
.
timezone
);
if
(
isZone
)
{
query
+=
'SET client_min_messages TO warning; SET TIME ZONE \''
+
self
.
sequelize
.
options
.
timezone
+
'\''
;
}
else
{
query
+=
'SET client_min_messages TO warning; SET TIME ZONE INTERVAL \''
+
self
.
sequelize
.
options
.
timezone
+
'\' HOUR TO MINUTE;'
;
}
}
}
// oids for hstore and geometry are dynamic - so select them at connection time
// oids for hstore and geometry are dynamic - so select them at connection time
...
...
test/integration/dialects/postgres/connection-manager.test.js
0 → 100644
View file @
b8e24d0
'use strict'
;
/* jshint -W030 */
var
chai
=
require
(
'chai'
)
,
expect
=
chai
.
expect
,
Support
=
require
(
__dirname
+
'/../../support'
)
,
dialect
=
Support
.
getTestDialect
()
,
DataTypes
=
require
(
__dirname
+
'/../../../../lib/data-types'
)
,
_
=
require
(
'lodash'
);
if
(
dialect
.
match
(
/^postgres/
))
{
describe
(
'[POSTGRES] Sequelize'
,
function
()
{
it
(
'should correctly parse the moment based timezone'
,
function
()
{
var
options
=
_
.
extend
(
this
.
sequelize
.
options
,
{
timezone
:
'Asia/Kolkata'
,
timestamps
:
true
});
var
sequelize
=
Support
.
createSequelizeInstance
(
options
);
var
tzTable
=
sequelize
.
define
(
'tz_table'
,
{
foo
:
DataTypes
.
STRING
});
return
tzTable
.
sync
({
force
:
true
}).
then
(
function
()
{
return
tzTable
.
create
({
foo
:
'test'
}).
then
(
function
(
row
)
{
expect
(
row
).
to
.
be
.
not
.
null
;
});
});
});
});
}
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