diff --git a/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs b/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs index dc08aa8ff..d69d350d3 100755 --- a/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs +++ b/Snowflake.Data.Tests/IntegrationTests/SFDbDataReaderIT.cs @@ -182,21 +182,26 @@ public void TestDateOutputFormat() conn.ConnectionString = ConnectionString; conn.Open(); - IDbCommand cmd = conn.CreateCommand(); - cmd.CommandText = "alter session set DATE_OUTPUT_FORMAT='MM/DD/YYYY'"; - cmd.ExecuteNonQuery(); - - cmd.CommandText = $"select TO_DATE('2013-05-17')"; - IDataReader reader = cmd.ExecuteReader(); + try + { + IDbCommand cmd = conn.CreateCommand(); + cmd.CommandText = "alter session set DATE_OUTPUT_FORMAT='MM/DD/YYYY'"; + cmd.ExecuteNonQuery(); - Assert.IsTrue(reader.Read()); - Assert.AreEqual("05/17/2013", reader.GetString(0)); + cmd.CommandText = $"select TO_DATE('2013-05-17')"; + IDataReader reader = cmd.ExecuteReader(); - reader.Close(); + Assert.IsTrue(reader.Read()); + Assert.AreEqual("05/17/2013", reader.GetString(0)); - // set format back to default to avoid impact other test cases - cmd.CommandText = "alter session set DATE_OUTPUT_FORMAT='YYYY-MM-DD'"; - cmd.ExecuteNonQuery(); + reader.Close(); + } + finally + { + // set format back to default to avoid impact other test cases + cmd.CommandText = "alter session set DATE_OUTPUT_FORMAT='YYYY-MM-DD'"; + cmd.ExecuteNonQuery(); + } conn.Close(); } diff --git a/Snowflake.Data/Core/Session/SFSession.cs b/Snowflake.Data/Core/Session/SFSession.cs index 5e78db2a9..52c6850e7 100755 --- a/Snowflake.Data/Core/Session/SFSession.cs +++ b/Snowflake.Data/Core/Session/SFSession.cs @@ -441,11 +441,11 @@ internal void UpdateDatabaseAndSchema(string databaseName, string schemaName) { // with HTAP session metadata removal database/schema // might be not returened in query result - if (databaseName != null) + if (!String.IsNullOrEmpty(databaseName)) { this.database = databaseName; } - if (schemaName != null) + if (!String.IsNullOrEmpty(schemaName)) { this.schema = schemaName; }