Title: [644] trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java: Bug for dates in insert_bind/update_bind
- Revision
- 644
- Author
- olabini
- Date
- 2007-06-19 12:13:51 -0400 (Tue, 19 Jun 2007)
Log Message
Bug for dates in insert_bind/update_bind
Modified Paths
Diff
Modified: trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java (643 => 644)
--- trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java 2007-06-19 12:54:56 UTC (rev 643)
+++ trunk/activerecord-jdbc/src/java/JdbcAdapterInternalService.java 2007-06-19 16:13:51 UTC (rev 644)
@@ -657,9 +657,18 @@
case Types.TIMESTAMP:
case Types.TIME:
case Types.DATE:
- java.sql.Timestamp ts = new java.sql.Timestamp(((RubyTime)value).getJavaDate().getTime());
- ts.setNanos((int)(((RubyTime)value).getUSec()*1000));
- ps.setTimestamp(index, ts, ((RubyTime)value).getJavaCalendar());
+ if(!(value instanceof RubyTime)) {
+ try {
+ Date dd = FORMAT.parse(RubyString.objAsString(value).toString());
+ ps.setTimestamp(index, new java.sql.Timestamp(dd.getTime()), Calendar.getInstance());
+ } catch(Exception e) {
+ ps.setString(index, RubyString.objAsString(value).toString());
+ }
+ } else {
+ java.sql.Timestamp ts = new java.sql.Timestamp(((RubyTime)value).getJavaDate().getTime());
+ ts.setNanos((int)(((RubyTime)value).getUSec()*1000));
+ ps.setTimestamp(index, ts, ((RubyTime)value).getJavaCalendar());
+ }
break;
case Types.BOOLEAN:
ps.setBoolean(index, value.isTrue());
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel