teiid SVN: r4598 - in branches/7.7.x: engine/src/main/java/org/teiid/query/function and 1 other directories.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2013-10-02 11:37:04 -0400 (Wed, 02 Oct 2013)
New Revision: 4598
Modified:
branches/7.7.x/common-core/src/main/java/org/teiid/core/util/TimestampWithTimezone.java
branches/7.7.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
branches/7.7.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
Log:
TEIID-2138 changing the pg standard_conforming_strings default
Modified: branches/7.7.x/common-core/src/main/java/org/teiid/core/util/TimestampWithTimezone.java
===================================================================
--- branches/7.7.x/common-core/src/main/java/org/teiid/core/util/TimestampWithTimezone.java 2013-09-26 19:07:45 UTC (rev 4597)
+++ branches/7.7.x/common-core/src/main/java/org/teiid/core/util/TimestampWithTimezone.java 2013-10-02 15:37:04 UTC (rev 4598)
@@ -46,9 +46,12 @@
*/
public class TimestampWithTimezone {
+ public static final String ISO8601_WEEK_PROP = "org.teiid.iso8601Week"; //$NON-NLS-1$
+ public static boolean ISO8601_WEEK = PropertiesUtils.getBooleanProperty(System.getProperties(), ISO8601_WEEK_PROP, false);
+
private static ThreadLocal<Calendar> CALENDAR = new ThreadLocal<Calendar>() {
protected Calendar initialValue() {
- return Calendar.getInstance();
+ return initialCalendar();
}
};
@@ -58,8 +61,17 @@
public static void resetCalendar(TimeZone tz) {
TimeZone.setDefault(tz);
- CALENDAR.set(Calendar.getInstance());
+ CALENDAR.set(initialCalendar());
}
+
+ static Calendar initialCalendar() {
+ Calendar result = Calendar.getInstance();
+ if (ISO8601_WEEK) {
+ result.setMinimalDaysInFirstWeek(4);
+ result.setFirstDayOfWeek(Calendar.MONDAY);
+ }
+ return result;
+ }
public static Object create(java.util.Date date, TimeZone initial, Calendar target, Class<?> type) {
if (type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2013-09-26 19:07:45 UTC (rev 4597)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2013-10-02 15:37:04 UTC (rev 4598)
@@ -390,8 +390,12 @@
// ================== Function = dayofweek =====================
- public static Object dayOfWeek(Date x) {
- return Integer.valueOf(getField(x, Calendar.DAY_OF_WEEK));
+ public static int dayOfWeek(Date x) {
+ int result = getField(x, Calendar.DAY_OF_WEEK);
+ if (TimestampWithTimezone.ISO8601_WEEK) {
+ return (result + 6) % 7;
+ }
+ return result;
}
// ================== Function = dayofyear =====================
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2013-09-26 19:07:45 UTC (rev 4597)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/transport/PgBackendProtocol.java 2013-10-02 15:37:04 UTC (rev 4598)
@@ -266,7 +266,7 @@
sendParameterStatus("server_encoding", "SQL_ASCII");
sendParameterStatus("server_version", "8.1.4");
sendParameterStatus("session_authorization", this.props.getProperty("user"));
- sendParameterStatus("standard_conforming_strings", "off");
+ sendParameterStatus("standard_conforming_strings", "on");
sendParameterStatus("application_name", this.props.getProperty("application_name", "ODBCClient"));
// TODO PostgreSQL TimeZone