Skip to content

Commit

Permalink
Rename property to JDBC_DEFAULT_FORMAT_DATE_WITH_TIMEZONE, revert tim…
Browse files Browse the repository at this point in the history
…ezone back to null to prevent BCR
  • Loading branch information
sfc-gh-ext-simba-nl committed Jul 15, 2024
1 parent 95789b7 commit 362981e
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/main/java/net/snowflake/client/core/SFSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 0 additions & 1 deletion src/test/java/net/snowflake/client/jdbc/BindingDataIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'), "
Expand Down Expand Up @@ -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)");
Expand Down
1 change: 0 additions & 1 deletion src/test/java/net/snowflake/client/loader/LoaderIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 362981e

Please sign in to comment.