Skip to content

Commit

Permalink
Changed according to comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pbulawa committed Jan 12, 2024
1 parent 3c9b728 commit b771acb
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions Snowflake.Data/Core/Session/SFSessionProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,7 @@ internal static SFSessionProperties parseConnectionString(String connectionStrin
ValidateFileTransferMaxBytesInMemoryProperty(properties);
ValidateAccountDomain(properties);

var allowUnderscoresInHost = bool.Parse(SFSessionProperty.ALLOWUNDERSCORESINHOST.GetAttribute<SFSessionPropertyAttr>().defaultValue);
if (properties.ContainsKey(SFSessionProperty.ALLOWUNDERSCORESINHOST))
{
try
{
allowUnderscoresInHost = bool.Parse(properties[SFSessionProperty.ALLOWUNDERSCORESINHOST]);
}
catch (Exception e)
{
logger.Warn("Unable to parse property 'allowUnderscoresInHost'", e);
}
}
var allowUnderscoresInHost = ParseAllowUnderscoresInHost(properties);

// compose host value if not specified
if (!properties.ContainsKey(SFSessionProperty.HOST) ||
Expand Down Expand Up @@ -399,6 +388,23 @@ private static bool IsRequired(SFSessionProperty sessionProperty, SFSessionPrope
return sessionProperty.GetAttribute<SFSessionPropertyAttr>().required;
}
}

private static bool ParseAllowUnderscoresInHost(SFSessionProperties properties)
{
var allowUnderscoresInHost = bool.Parse(SFSessionProperty.ALLOWUNDERSCORESINHOST.GetAttribute<SFSessionPropertyAttr>().defaultValue);
if (!properties.TryGetValue(SFSessionProperty.ALLOWUNDERSCORESINHOST, out var property))
return allowUnderscoresInHost;

Check warning on line 396 in Snowflake.Data/Core/Session/SFSessionProperty.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Core/Session/SFSessionProperty.cs#L396

Added line #L396 was not covered by tests
try
{
allowUnderscoresInHost = bool.Parse(property);
}
catch (Exception e)
{
logger.Warn("Unable to parse property 'allowUnderscoresInHost'", e);
}

Check warning on line 404 in Snowflake.Data/Core/Session/SFSessionProperty.cs

View check run for this annotation

Codecov / codecov/patch

Snowflake.Data/Core/Session/SFSessionProperty.cs#L401-L404

Added lines #L401 - L404 were not covered by tests

return allowUnderscoresInHost;
}
}

public static class EnumExtensions
Expand Down

0 comments on commit b771acb

Please sign in to comment.