From 362981e45a53fac5430c5b058933b62b809b80d8 Mon Sep 17 00:00:00 2001 From: norrislee Date: Mon, 15 Jul 2024 14:12:01 -0700 Subject: [PATCH] Rename property to JDBC_DEFAULT_FORMAT_DATE_WITH_TIMEZONE, revert timezone back to null to prevent BCR --- src/main/java/net/snowflake/client/core/SFSession.java | 2 +- .../java/net/snowflake/client/core/SFSessionProperty.java | 5 ++++- .../net/snowflake/client/jdbc/SnowflakeBaseResultSet.java | 2 +- .../net/snowflake/client/jdbc/SnowflakeBasicDataSource.java | 2 +- src/test/java/net/snowflake/client/jdbc/BindingDataIT.java | 1 - .../java/net/snowflake/client/jdbc/ResultSetAsyncIT.java | 1 - .../snowflake/client/jdbc/ResultSetJsonVsArrowMultiTZIT.java | 1 - .../net/snowflake/client/jdbc/ResultSetMultiTimeZoneIT.java | 3 --- src/test/java/net/snowflake/client/loader/LoaderIT.java | 1 - 9 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main/java/net/snowflake/client/core/SFSession.java b/src/main/java/net/snowflake/client/core/SFSession.java index 64a1cf5ec..4c070bd2d 100644 --- a/src/main/java/net/snowflake/client/core/SFSession.java +++ b/src/main/java/net/snowflake/client/core/SFSession.java @@ -486,7 +486,7 @@ public void addSFSessionProperty(String propertyName, Object propertyValue) thro } break; - case JDBC_USE_HARDCODED_TIMEZONE: + case JDBC_DEFAULT_FORMAT_DATE_WITH_TIMEZONE: if (propertyValue != null) { setUseHardcodedTimezone(getBooleanValue(propertyValue)); } diff --git a/src/main/java/net/snowflake/client/core/SFSessionProperty.java b/src/main/java/net/snowflake/client/core/SFSessionProperty.java index 53e6fd6a1..f8e499cf0 100644 --- a/src/main/java/net/snowflake/client/core/SFSessionProperty.java +++ b/src/main/java/net/snowflake/client/core/SFSessionProperty.java @@ -88,7 +88,10 @@ public enum SFSessionProperty { DISABLE_SAML_URL_CHECK("disableSamlURLCheck", false, Boolean.class), - JDBC_USE_HARDCODED_TIMEZONE("JDBC_USE_HARDCODED_TIMEZONE", false, Boolean.class); + // Used to determine whether a hardcoded value should be used for the formatter (for backwards + // compatibility) + JDBC_DEFAULT_FORMAT_DATE_WITH_TIMEZONE( + "JDBC_DEFAULT_FORMAT_DATE_WITH_TIMEZONE", false, Boolean.class); // property key in string private String propertyKey; diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeBaseResultSet.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeBaseResultSet.java index 30785e5fb..d191b646c 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeBaseResultSet.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeBaseResultSet.java @@ -134,7 +134,7 @@ protected void raiseSQLExceptionIfResultSetIsClosed() throws SQLException { @Override public Date getDate(int columnIndex) throws SQLException { raiseSQLExceptionIfResultSetIsClosed(); - return getDate(columnIndex, TimeZone.getDefault()); + return getDate(columnIndex, (TimeZone) null); } @Override diff --git a/src/main/java/net/snowflake/client/jdbc/SnowflakeBasicDataSource.java b/src/main/java/net/snowflake/client/jdbc/SnowflakeBasicDataSource.java index e8b55526d..ebb2e74dc 100644 --- a/src/main/java/net/snowflake/client/jdbc/SnowflakeBasicDataSource.java +++ b/src/main/java/net/snowflake/client/jdbc/SnowflakeBasicDataSource.java @@ -233,6 +233,6 @@ public void setTracing(String tracing) { } public void setUseHardcodedTimezone(Boolean useHardcodedTimezone) { - this.properties.put("JDBC_USE_HARDCODED_TIMEZONE", useHardcodedTimezone); + this.properties.put("JDBC_DEFAULT_FORMAT_DATE_WITH_TIMEZONE", useHardcodedTimezone); } } diff --git a/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java b/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java index fd4afe96e..1b7387792 100644 --- a/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java +++ b/src/test/java/net/snowflake/client/jdbc/BindingDataIT.java @@ -335,7 +335,6 @@ public void testBindDate(Date dateValue) throws SQLException { try (Connection connection = getConnection(); Statement statement = connection.createStatement()) { try { - statement.execute("alter session set JDBC_FORMAT_DATE_WITH_TIMEZONE=FALSE"); statement.execute("create or replace table test_bind_date(c1 date)"); try (PreparedStatement preparedStatement = diff --git a/src/test/java/net/snowflake/client/jdbc/ResultSetAsyncIT.java b/src/test/java/net/snowflake/client/jdbc/ResultSetAsyncIT.java index 42b9508d0..1351ea4f1 100644 --- a/src/test/java/net/snowflake/client/jdbc/ResultSetAsyncIT.java +++ b/src/test/java/net/snowflake/client/jdbc/ResultSetAsyncIT.java @@ -270,7 +270,6 @@ public void testGetMethods() throws Throwable { prepStatement.setTimestamp(14, ts); prepStatement.execute(); - statement.execute("alter session set JDBC_FORMAT_DATE_WITH_TIMEZONE=FALSE"); try (ResultSet resultSet = statement .unwrap(SnowflakeStatement.class) diff --git a/src/test/java/net/snowflake/client/jdbc/ResultSetJsonVsArrowMultiTZIT.java b/src/test/java/net/snowflake/client/jdbc/ResultSetJsonVsArrowMultiTZIT.java index cf5d498aa..6add203f5 100644 --- a/src/test/java/net/snowflake/client/jdbc/ResultSetJsonVsArrowMultiTZIT.java +++ b/src/test/java/net/snowflake/client/jdbc/ResultSetJsonVsArrowMultiTZIT.java @@ -114,7 +114,6 @@ public void testDate() throws Exception { String values = "('" + StringUtils.join(cases, "'),('") + "'), (null)"; try (Connection con = init(table, column, values); Statement statement = con.createStatement()) { - statement.execute("alter session set JDBC_FORMAT_DATE_WITH_TIMEZONE=FALSE"); try (ResultSet rs = statement.executeQuery("select * from " + table)) { int i = 0; while (i < cases.length) { diff --git a/src/test/java/net/snowflake/client/jdbc/ResultSetMultiTimeZoneIT.java b/src/test/java/net/snowflake/client/jdbc/ResultSetMultiTimeZoneIT.java index d50d648f2..c0a494613 100644 --- a/src/test/java/net/snowflake/client/jdbc/ResultSetMultiTimeZoneIT.java +++ b/src/test/java/net/snowflake/client/jdbc/ResultSetMultiTimeZoneIT.java @@ -137,7 +137,6 @@ public void testGetDateAndTime() throws SQLException { try (Connection connection = init(); Statement statement = connection.createStatement()) { try { - statement.execute("alter session set JDBC_FORMAT_DATE_WITH_TIMEZONE=FALSE"); statement.execute("create or replace table dateTime(colA Date, colB Timestamp, colC Time)"); java.util.Date today = new java.util.Date(); @@ -322,7 +321,6 @@ public void testGetOldDate() throws SQLException { try (Connection connection = init(); Statement statement = connection.createStatement()) { try { - statement.execute("alter session set JDBC_FORMAT_DATE_WITH_TIMEZONE=FALSE"); statement.execute("create or replace table testOldDate(d date)"); statement.execute( "insert into testOldDate values ('0001-01-01'), " @@ -378,7 +376,6 @@ public void testDateTimeRelatedTypeConversion() throws SQLException { try (Connection connection = init(); Statement statement = connection.createStatement()) { try { - statement.execute("alter session set JDBC_FORMAT_DATE_WITH_TIMEZONE=FALSE"); statement.execute( "create or replace table testDateTime" + "(colDate DATE, colTS timestamp_ltz, colTime TIME, colString string)"); diff --git a/src/test/java/net/snowflake/client/loader/LoaderIT.java b/src/test/java/net/snowflake/client/loader/LoaderIT.java index 00b0d9b2d..00fea060f 100644 --- a/src/test/java/net/snowflake/client/loader/LoaderIT.java +++ b/src/test/java/net/snowflake/client/loader/LoaderIT.java @@ -145,7 +145,6 @@ public void testLoadTime() throws Exception { } assertThat(String.format("Error: %s", errorMessage), listener.getErrorCount(), equalTo(0)); try (Statement statement = testConnection.createStatement()) { - statement.executeQuery("alter session set JDBC_FORMAT_DATE_WITH_TIMEZONE=FALSE"); try (ResultSet rs = statement.executeQuery(String.format("SELECT c1, c2 FROM %s LIMIT 1", tableName))) { assertTrue(rs.next());