8000 Including spec with an explicit timezone setting · mst-appear/postgresql-async@32648ea · GitHub
[go: up one dir, main page]

Skip to content

Commit 32648ea

Browse files
committed
Including spec with an explicit timezone setting
1 parent 48d3273 commit 32648ea

File tree

5 files changed

+33
-4
lines changed

5 files changed

+33
-4
lines changed

postgresql-async/src/main/scala/com/github/mauricio/async/db/postgresql/codec/PostgreSQLConnectionHandler.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ class PostgreSQLConnectionHandler
138138
case ServerMessage.BindComplete => {
139139
}
140140
case ServerMessage.Authentication => {
141+
log.debug("Authentication response received {}", m)
141142
connectionDelegate.onAuthenticationResponse(m.asInstanceOf[AuthenticationMessage])
142143
}
143144
case ServerMessage.CommandComplete => {
@@ -164,13 +165,11 @@ class PostgreSQLConnectionHandler
164165
connectionDelegate.onParameterStatus(m.asInstanceOf[ParameterStatusMessage])
165166
}
166167
case ServerMessage.ParseComplete => {
167-
log.debug("Parse complete received - {}", m)
168168
}
169169
case ServerMessage.ReadyForQuery => {
170170
connectionDelegate.onReadyForQuery()
171171
}
172172
case ServerMessage.RowDescription => {
173-
log.debug("Row description received - {}", m)
174173
connectionDelegate.onRowDescription(m.asInstanceOf[RowDescriptionMessage])
175174
}
176175
case _ => {

postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/DatabaseTestHelper.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,28 @@ trait DatabaseTestHelper {
3232

3333
def databaseName = Some("netty_driver_test")
3434

35+
def timeTestDatabase = Some("netty_driver_time_test")
36+
3537
def databasePort = 5432
3638

3739
def defaultConfiguration = new Configuration(
3840
port = databasePort,
3941
username = "postgres",
4042
database = databaseName)
4143

44+
def timeTestConfiguration = new Configuration(
45+
port = databasePort,
46+
username = "postgres",
47+
database = timeTestDatabase)
48+
4249
def withHandler[T](fn: (PostgreSQLConnection) => T): T = {
4350
withHandler(this.defaultConfiguration, fn)
4451
}
4552

53+
def withTimeHandler[T](fn: (PostgreSQLConnection) => T): T = {
54+
withHandler(this.timeTestConfiguration, fn)
55+
}
56+
4657
def withHandler[T](configuration: Configuration, fn: (PostgreSQLConnection) => T): T = {
4758

4859
val handler = new PostgreSQLConnection(configuration)

postgresql-async/src/test/scala/com/github/mauricio/async/db/postgresql/TimeAndDateSpec.scala

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,23 @@ class TimeAndDateSpec extends Specification with DatabaseTestHelper {
186186
}
187187
}
188188

189+
"handle a change in timezone inside the connection" in {
190+
191+
withTimeHandler {
192+
conn =>
193+
val date1 = new DateTime(2190319)
194+
195+
await(conn.sendPreparedStatement(s"alter database ${databaseName.get} set timezone to 'GMT'"))
196+
await(conn.sendPreparedStatement("CREATE TEMP TABLE TEST(T TIMESTAMP)"))
197+
await(conn.sendPreparedStatement("INSERT INTO TEST(T) VALUES(?)", Seq(date1)))
198+
val result = await(conn.sendPreparedStatement("SELECT T FROM TEST"))
199+
val date2 = result.rows.get.head(0)
200+
201+
date2 === date1
202+
}
203+
204+
}
205+
189206
}
190207

191208
}

project/Build.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ object Configuration {
5656
"joda-time" % "joda-time" % "2.2",
5757
"org.joda" % "joda-convert" % "1.3.1",
5858
"org.scala-lang" % "scala-library" % "2.10.2",
59-
"io.netty" % "netty-all" % "4.0.9.Final",
59+
"io.netty" % "netty-all" % "4.0.11.Final",
60+
"org.javassist" % "javassist" % "3.18.1-GA",
6061
specs2Dependency,
6162
logbackDependency
6263
)
@@ -74,7 +75,7 @@ object Configuration {
7475
:+ "-feature"
7576
,
7677
scalacOptions in doc := Seq("-doc-external-doc:scala=http://www.scala-lang.org/archives/downloads/distrib/files/nightly/docs/library/"),
77-
scalaVersion := "2.10.2",
78+
scalaVersion := "2.10.3",
7879
javacOptions := Seq("-source", "1.5", "-target", "1.5", "-encoding", "UTF8"),
7980
organization := "com.github.mauricio",
8081
version := commonVersion,

script/prepare_build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'mysql_async'@'localhost' IDENT
77
echo "preparing postgresql configs"
88

99
psql -c 'create database netty_driver_test;' -U postgres
10+
psql -c 'create database netty_driver_time_test;' -U postgres
1011
psql -c "CREATE USER postgres_md5 WITH PASSWORD 'postgres_md5'; GRANT ALL PRIVILEGES ON DATABASE netty_driver_test to postgres_md5;" -U postgres
1112
psql -c "CREATE USER postgres_cleartext WITH PASSWORD 'postgres_cleartext'; GRANT ALL PRIVILEGES ON DATABASE netty_driver_test to postgres_cleartext;" -U postgres
1213
psql -c "CREATE USER postgres_kerberos WITH PASSWORD 'postgres_kerberos'; GRANT ALL PRIVILEGES ON DATABASE netty_driver_test to postgres_kerberos;" -U postgres

0 commit comments

Comments
 (0)
0