File tree Expand file tree Collapse file tree 4 files changed +20
-28
lines changed
main/scala/com/github/mauricio/async/db/postgresql
test/scala/com/github/mauricio/async/db/postgresql Expand file tree Collapse file tree 4 files changed +20
-28
lines changed Original file line number Diff line number Diff line change 1
- postgresql : /usr/local/Cellar/postgresql/9.2.4/bin/ postgres -D /Users/mauricio/databases/postgresql
1
+ postgresql : postgres -D /Users/mauricio/databases/postgresql
2
2
mysql : mysqld --log-warnings --console
Original file line number Diff line number Diff line change @@ -61,24 +61,28 @@ object PostgreSQLTimestampEncoderDecoder extends ColumnEncoderDecoder {
61
61
62
62
val format = columnType.dataType match {
63
63
case ColumnTypes .Timestamp | ColumnTypes .TimestampArray | ColumnTypes .TimestampWithTimezoneArray => {
64
- if ( text.contains(" ." ) ) {
65
- internalFormatters(5 )
66
- } else {
67
- internalFormatterWithoutSeconds
68
- }
64
+ selectFormatter(text)
69
65
}
70
66
case ColumnTypes .TimestampWithTimezone => {
71
67
if ( columnType.dataTypeModifier > 0 ) {
72
68
internalFormatters(columnType.dataTypeModifier - 1 )
73
69
} else {
74
- internalFormatterWithoutSeconds
70
+ selectFormatter(text)
75
71
}
76
72
}
77
73
}
78
74
79
75
format.parseDateTime(text)
80
76
}
81
77
78
+ private def selectFormatter ( text : String ) = {
79
+ if ( text.contains(" ." ) ) {
80
+ internalFormatters(5 )
81
+ } else {
82
+ internalFormatterWithoutSeconds
83
+ }
84
+ }
85
+
82
86
override def decode (value : String ) : Any = throw new UnsupportedOperationException (" this method should not have been called" )
83
87
84
88
override def encode (value : Any ): String = {
Original file line number Diff line number Diff line change @@ -18,11 +18,11 @@ package com.github.mauricio.async.db.postgresql.messages.backend
18
18
19
19
import com .github .mauricio .async .db .general .ColumnData
20
20
21
- class PostgreSQLColumnData (
22
- val name : String ,
23
- val tableObjectId : Int ,
24
- val columnNumber : Int ,
25
- val dataType : Int ,
26
- val dataTypeSize : Long ,
27
- val dataTypeModifier : Int ,
28
- val fieldFormat : Int ) extends ColumnData
21
+ case class PostgreSQLColumnData (
22
+ name : String ,
23
+ tableObjectId : Int ,
24
+ columnNumber : Int ,
25
+ dataType : Int ,
26
+ dataTypeSize : Long ,
27
+ dataTypeModifier : Int ,
28
+ fieldFormat : Int ) extends ColumnData
Original file line number Diff line number Diff line change @@ -161,18 +161,6 @@ class TimeAndDateSpec extends Specification with DatabaseTestHelper {
161
161
}
162
162
}
163
163
164
- /* TODO postgresql-async cannnot parse timestamp value which is set by current_timestamp
165
-
166
- [info] ! support current_timestamp with timezone
167
- [error] IllegalArgumentException: Invalid format: "2013-10-06 22:56:21.459635+09" is malformed at ".459635+09" (DateTimeFormatter.java:871)
168
- [error] org.joda.time.format.DateTimeFormatter.parseDateTime(DateTimeFormatter.java:871)
169
- [error] com.github.mauricio.async.db.postgresql.column.PostgreSQLTimestampEncoderDecoder$.decode(PostgreSQLTimestampEncoderDecoder.scala:79)
170
- [error] com.github.mauricio.async.db.postgresql.column.PostgreSQLColumnDecoderRegistry.decode(PostgreSQLColumnDecoderRegistry.scala:49)
171
- [error] com.github.mauricio.async.db.postgresql.PostgreSQLConnection.onDataRow(PostgreSQLConnection.scala:220)
172
- [error] com.github.mauricio.async.db.postgresql.codec.PostgreSQLConnectionHandler.channelRead0(PostgreSQLConnectionHandler.scala:149)
173
- [error] io.netty.channel.SimpleChannelInboundHandler.channelRead(SimpleChannelInboundHandler.java:98)
174
- [error] io.netty.channel.DefaultChannelHandlerContext.invokeChannelRead(DefaultChannelHandlerContext.java:337)
175
- */
176
164
" support current_timestamp with timezone" in {
177
165
withHandler {
178
166
handler =>
@@ -194,7 +182,7 @@ class TimeAndDateSpec extends Specification with DatabaseTestHelper {
194
182
195
183
val dateTime = rows(0 )(" moment" ).asInstanceOf [DateTime ]
196
184
197
- dateTime.getMillis must be_ >= (millis)
185
+ dateTime.getMillis must beCloseTo (millis, 100 )
198
186
}
199
187
}
200
188
You can’t perform that action at this time.
0 commit comments