Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Snowflake.Data/Core/Session/SFSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ internal Uri BuildLoginUrl()
string schemaValue;
string roleName;
queryParams[RestParams.SF_QUERY_WAREHOUSE] = properties.TryGetValue(SFSessionProperty.WAREHOUSE, out warehouseValue) ? warehouseValue : "";
queryParams[RestParams.SF_QUERY_DB] = properties.TryGetValue(SFSessionProperty.DB, out dbValue) ? dbValue : "";
queryParams[RestParams.SF_QUERY_SCHEMA] = properties.TryGetValue(SFSessionProperty.SCHEMA, out schemaValue) ? schemaValue : "";
queryParams[RestParams.SF_QUERY_DB] = EscapeDbObjectForUrl(properties.TryGetValue(SFSessionProperty.DB, out dbValue) ? dbValue : "");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide some unit tests for this change?

queryParams[RestParams.SF_QUERY_SCHEMA] = EscapeDbObjectForUrl(properties.TryGetValue(SFSessionProperty.SCHEMA, out schemaValue) ? schemaValue : "");
queryParams[RestParams.SF_QUERY_ROLE] = properties.TryGetValue(SFSessionProperty.ROLE, out roleName) ? roleName : "";
queryParams[RestParams.SF_QUERY_REQUEST_ID] = Guid.NewGuid().ToString();
queryParams[RestParams.SF_QUERY_REQUEST_GUID] = Guid.NewGuid().ToString();
Expand All @@ -129,6 +129,11 @@ internal Uri BuildLoginUrl()
return loginUrl;
}

private string EscapeDbObjectForUrl(string name)
{
return name == string.Empty ? name : $"\"{name.Replace("\"", "\"\"")}\"";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please make sure the name isn't already wrapped with quotes.
Make sure if connection tests are passing after this fix.

}

/// <summary>
/// Constructor
/// </summary>
Expand Down