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

Fix | Add correct code page for Kazakh collation #584

Merged
merged 1 commit into from
Jun 10, 2020
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -4258,6 +4258,9 @@ internal int GetCodePage(SqlCollation collation, TdsParserStateObject stateObj)
{
}
break;
case 0x43f:
codePage = 1251; // Kazakh code page based on SQL Server
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4725,6 +4725,9 @@ internal int GetCodePage(SqlCollation collation, TdsParserStateObject stateObj)
ADP.TraceExceptionWithoutRethrow(e);
}
break;
case 0x43f:
codePage = 1251; // Kazakh code page based on SQL Server
break;
default:
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Threading;
using Xunit;

namespace Microsoft.Data.SqlClient.ManualTesting.Tests
Expand Down Expand Up @@ -145,6 +146,60 @@ public static void CheckSparseColumnBit()
}
}

[ConditionalFact(typeof(DataTestUtility), nameof(DataTestUtility.AreConnStringsSetup), nameof(DataTestUtility.IsNotAzureServer))]
cheenamalhotra marked this conversation as resolved.
Show resolved Hide resolved
public static void CollatedDataReaderTest()
{
var databaseName = DataTestUtility.GetUniqueName("DB");
// Remove square brackets
var dbName = databaseName.Substring(1, databaseName.Length - 2);

SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(DataTestUtility.TCPConnectionString)
{
InitialCatalog = dbName,
Pooling = false
};

using (SqlConnection con = new SqlConnection(DataTestUtility.TCPConnectionString))
using (SqlCommand cmd = con.CreateCommand())
{
try
{
con.Open();

// Create collated database
cmd.CommandText = $"CREATE DATABASE {databaseName} COLLATE KAZAKH_90_CI_AI";
cmd.ExecuteNonQuery();

//Create connection without pooling in order to delete database later.
using (SqlConnection dbCon = new SqlConnection(builder.ConnectionString))
using (SqlCommand dbCmd = dbCon.CreateCommand())
{
var data = "TestData";

dbCon.Open();
dbCmd.CommandText = $"SELECT '{data}'";
using (SqlDataReader reader = dbCmd.ExecuteReader())
{
reader.Read();
Assert.Equal(data, reader.GetString(0));
}
}

// Let connection close safely before dropping database for slow servers.
Thread.Sleep(500);
}
catch (SqlException e)
{
Assert.True(false, $"Unexpected Exception occurred: {e.Message}");
}
finally
{
cmd.CommandText = $"DROP DATABASE {databaseName}";
cmd.ExecuteNonQuery();
}
}
}

private static bool IsColumnBitSet(SqlConnection con, string selectQuery, int indexOfColumnSet)
{
bool columnSetPresent = false;
Expand Down