henning 2004/09/06 04:20:12 Modified: src/java/org/apache/torque/adapter Tag: TORQUE_3_1_BRANCH DBPostgres.java xdocs Tag: TORQUE_3_1_BRANCH release-changes.xml Log: Another of the "huh, how could this ever work?" bugs. Deleting an object containing a timestamp didn't work, because the PostgreSQL adapter was missing a method to convert the timestamp to the postgres format. So the default [ts: <java.util.Date>] text was used, which (of course) returned an error from the JDBC driver. Probably selecting and updating didn't work, either. Well, timestamps don't seem to be much in use these days. ;-) Revision Changes Path No revision No revision 1.16.2.3 +31 -1 db-torque/src/java/org/apache/torque/adapter/DBPostgres.java Index: DBPostgres.java =================================================================== RCS file: /home/cvs/db-torque/src/java/org/apache/torque/adapter/DBPostgres.java,v retrieving revision 1.16.2.2 retrieving revision 1.16.2.3 diff -u -r1.16.2.2 -r1.16.2.3 --- DBPostgres.java 20 May 2004 04:35:15 -0000 1.16.2.2 +++ DBPostgres.java 6 Sep 2004 11:20:12 -0000 1.16.2.3 @@ -18,6 +18,8 @@ import java.sql.Connection; import java.sql.SQLException; +import java.text.SimpleDateFormat; +import java.util.Date; /** * This is used to connect to PostgresQL databases. @@ -25,15 +27,23 @@ * <a href="http://www.postgresql.org/">http://www.postgresql.org/</a> * * @author <a href="mailto:[EMAIL PROTECTED]">Hakan Tandogan</a> + * @author <a href="mailto:[EMAIL PROTECTED]">Henning P. Schmiedehausen</a> * @version $Id$ */ public class DBPostgres extends DB { + + /** A specialized date format for PostgreSQL. */ + private static final String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss"; + + private SimpleDateFormat sdf = null; + /** * Empty constructor. */ protected DBPostgres() { + sdf = new SimpleDateFormat(DATE_FORMAT); } /** @@ -143,5 +153,25 @@ public String getBooleanString(Boolean b) { return (b == null) ? "0" : (Boolean.TRUE.equals(b) ? "1" : "0"); + } + + /** + * This method overrides the JDBC escapes used to format dates + * using a <code>DateFormat</code>. + * + * This generates the timedate format defined in + * http://www.postgresql.org/docs/7.3/static/datatype-datetime.html + * which defined PostgreSQL dates as YYYY-MM-DD hh:mm:ss + * @param date the date to format + * @return The properly formatted date String. + */ + public String getDateString(Date date) + { + StringBuffer dateBuf = new StringBuffer(); + char delim = getStringDelimiter(); + dateBuf.append(delim); + dateBuf.append(sdf.format(date)); + dateBuf.append(delim); + return dateBuf.toString(); } } No revision No revision 1.3.2.25 +10 -3 db-torque/xdocs/release-changes.xml Index: release-changes.xml =================================================================== RCS file: /home/cvs/db-torque/xdocs/release-changes.xml,v retrieving revision 1.3.2.24 retrieving revision 1.3.2.25 diff -u -r1.3.2.24 -r1.3.2.25 --- release-changes.xml 4 Sep 2004 13:59:51 -0000 1.3.2.24 +++ release-changes.xml 6 Sep 2004 11:20:12 -0000 1.3.2.25 @@ -10,7 +10,7 @@ <body> -<section name="Torque 3.1.1-rc3."> +<section name="Torque 3.1.1-rc3"> <p> Changes between Torque 3.1.1-rc2 and 3.1.1-rc3.<br/> </p> @@ -38,11 +38,18 @@ Price for the patch. </li> </ul> + <ul> + <li> + Deleting an Object containing a timestamp didn't work with PostgreSQL (the + adapter was missing the necessary method to convert the timestamp into a value + that is understood by the databases). + </li> + </ul> </p> </subsection> </section> -<section name="Torque 3.1.1-rc2."> +<section name="Torque 3.1.1-rc2"> <p> Changes between Torque 3.1.1-rc1 and 3.1.1-rc2.<br/> </p> @@ -61,7 +68,7 @@ </subsection> </section> -<section name="Torque 3.1.1-rc1."> +<section name="Torque 3.1.1-rc1"> <p> Changes between Torque 3.1 and 3.1.1-rc1.<br/> </p>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]