diff --git a/.pipelines/dwsql-pipelines.yml b/.pipelines/dwsql-pipelines.yml index a1f29ff616..42bb739892 100644 --- a/.pipelines/dwsql-pipelines.yml +++ b/.pipelines/dwsql-pipelines.yml @@ -50,6 +50,14 @@ jobs: dockerVersion: 17.09.0-ce releaseType: stable + - task: Bash@3 + displayName: 'Bash generate password' + inputs: + targetType: 'inline' + script: | + password=$(cat /dev/urandom | tr -dc 'A-Za-z0-9_!@#$%^&*()\-+=' | head -c24) + echo "##vso[task.setvariable variable=DockerSQLPass;issecret=true]$password" + - task: Bash@3 condition: eq( variables['Agent.OS'], 'Linux' ) displayName: Get and Start Ubuntu SQL Server Image Docker with SSL enabled diff --git a/config-generators/config-generator.sh b/config-generators/config-generator.sh index 0a88763f9b..e1f10b679c 100755 --- a/config-generators/config-generator.sh +++ b/config-generators/config-generator.sh @@ -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"; + 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; @@ -47,6 +51,9 @@ do elif [[ $databaseType == "postgresql" ]]; then commandFile="postgresql-commands.txt"; configFile="dab-config.PostgreSql.json"; + elif [[ $databaseType == "dwsql" ]]; then + commandFile="dwsql-commands.txt"; + configFile="dab-config.DwSql.json"; else commandFile="cosmosdb_nosql-commands.txt"; configFile="dab-config.CosmosDb_NoSql.json"; diff --git a/src/Core/Resolvers/DWSqlQueryBuilder.cs b/src/Core/Resolvers/DWSqlQueryBuilder.cs index 2d45496531..59610189d3 100644 --- a/src/Core/Resolvers/DWSqlQueryBuilder.cs +++ b/src/Core/Resolvers/DWSqlQueryBuilder.cs @@ -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')"); } 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++; @@ -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("+\',\'+"); } } - columns = $"STRING_AGG(\'{{{stringAgg}}}\',', ')"; + columns = $"STRING_AGG(\'{{\'+{stringAgg}+\'}}\',', ')"; if (structure.IsListQuery) { // Array wrappers if we are trying to get a list of objects.