Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing dw query builder to handle Unicode characters #1901

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 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
14 changes: 9 additions & 5 deletions config-generators/config-generator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,19 @@ databaseTypes=();
# The argument represents the database type. Valid arguments are MsSql, MySql, PostgreSql and Cosmos
# When invoked with a database type, config file for that database type will be generated.
# When invoked without any arguments, config files for all the database types will be generated.

allowedDbTypes=("mssql" "mysql" "postgresql" "cosmosdb_nosql" "dwsql")
databaseTypes=()

if [[ $# -eq 0 ]]; then
databaseTypes=("mssql" "mysql" "postgresql" "cosmosdb_nosql")
databaseTypes=("${allowedDbTypes[@]}")
elif [[ $# -eq 1 ]]; then
databaseType=$1;
if ! { [ $databaseType == "mssql" ] || [ $databaseType == "mysql" ] || [ $databaseType == "postgresql" ] || [ $databaseType == "cosmosdb_nosql" ]; }; then
echo "Valid arguments are mssql, mysql, postgresql or cosmosdb_nosql";
databaseType=$1
if [[ ! ${allowedDbTypes[@]} =~ ${databaseType} ]]; then
echo "Valid arguments are mssql, mysql, postgresql, cosmosdb_nosql, or dwsql";
exit 1;
fi
databaseTypes+=$databaseType;
databaseTypes+=$databaseType;
else
echo "Please run with 0 or 1 arguments";
exit 1;
Expand Down
8 changes: 4 additions & 4 deletions src/Core/Resolvers/DWSqlQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@ private static string GenerateColumnsAsJson(SqlQueryStructure structure, bool su
{
col_value = $"CAST([{col_value}] AS NVARCHAR(MAX))";
// Create json. Example: "book.id": 1 would be a sample output.
stringAgg.Append($"\"{escapedLabel}\":\' + ISNULL(STRING_ESCAPE({col_value},'json'),'null') + \'");
stringAgg.Append($"N\'\"{escapedLabel}\":\' + ISNULL(STRING_ESCAPE({col_value},'json'),'null')");
rohkhann marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
// Create json. Example: "book.title": "Title" would be a sample output.
stringAgg.Append($"\"{escapedLabel}\":\' + ISNULL(\'\"\'+STRING_ESCAPE([{col_value}],'json')+\'\"\','null') + \'");
stringAgg.Append($"N\'\"{escapedLabel}\":\' + ISNULL(\'\"\'+STRING_ESCAPE([{col_value}],'json')+\'\"\','null')");
}

i++;
Expand All @@ -123,11 +123,11 @@ private static string GenerateColumnsAsJson(SqlQueryStructure structure, bool su
// the below ensures there is a comma after id but not after name.
if (i != structure.Columns.Count)
{
stringAgg.Append(",");
stringAgg.Append("+\',\'+");
seantleonard marked this conversation as resolved.
Show resolved Hide resolved
}
}

columns = $"STRING_AGG(\'{{{stringAgg}}}\',', ')";
columns = $"STRING_AGG(\'{{\'+{stringAgg}+\'}}\',', ')";
if (structure.IsListQuery)
{
// Array wrappers if we are trying to get a list of objects.
Expand Down