Skip to content

Commit

Permalink
v3.1.1 (#216)
Browse files Browse the repository at this point in the history
- Bugfix: MySQL text was erroneously capped at 64k (TEXT) instead of LONGTEXT (4GiB)
- Adjust timeout handling, use 10 seconds not 3 for server live tests since our Azure VM is slow
- Bump MySqlConnector from 2.2.6 to 2.2.7
- Bump Oracle.ManagedDataAccess.Core from 3.21.100 to 3.21.110
  • Loading branch information
jas88 committed Sep 6, 2023
1 parent 7107c7b commit 8c33145
Show file tree
Hide file tree
Showing 17 changed files with 70 additions and 56 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-core.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
- name: Disable write flush for CI runs
run: sudo apt-get install -y libeatmydata1 apt-transport-https curl
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup .NET Core
uses: actions/setup-dotnet@v3
with:
Expand Down
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [3.1.1] - 2023-09-01

- Bugfix: MySQL text was erroneously capped at 64k (TEXT) instead of LONGTEXT (4GiB)
- Adjust timeout handling, use 10 seconds not 3 for server live tests since our Azure VM is slow
- Bump MySqlConnector from 2.2.6 to 2.2.7
- Bump Oracle.ManagedDataAccess.Core from 3.21.100 to 3.21.110

## [3.1.0] - 2023-05-15

Expand Down Expand Up @@ -349,7 +354,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Fixed Drop table to work correctly with Views
- Exists now works correctly for Views (previously it would return true if there was no view but a table with the same name)

[Unreleased]: https://github.com/HicServices/FAnsiSql/compare/3.1.0...develop
[Unreleased]: https://github.com/HicServices/FAnsiSql/compare/3.1.1...develop
[3.1.1]: https://github.com/HicServices/FAnsiSql/compare/3.1.0...3.1.1
[3.1.0]: https://github.com/HicServices/FAnsiSql/compare/3.0.1...3.1.0
[3.0.1]: https://github.com/HicServices/FAnsiSql/compare/3.0.0...3.0.1
[3.0.0]: https://github.com/HicServices/FAnsiSql/compare/2.0.5...3.0.0
Expand Down
8 changes: 4 additions & 4 deletions FAnsiSql/DatabaseOperationArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class DatabaseOperationArgs

public DatabaseOperationArgs()
{

}
public DatabaseOperationArgs(IManagedTransaction transactionIfAny, CancellationToken cancellationToken, int timeoutInSeconds)
{
Expand Down Expand Up @@ -66,7 +66,7 @@ private T Execute<T>(DbCommand cmd, Func<Task<T>> method)
{
Hydrate(cmd);
var t = method();

try
{
switch (t.Status)
Expand All @@ -86,7 +86,7 @@ private T Execute<T>(DbCommand cmd, Func<Task<T>> method)
throw e.InnerExceptions[0];
throw;
}

if (!t.IsCompleted)
cmd.Cancel();

Expand All @@ -103,7 +103,7 @@ public void Fill(DbDataAdapter da, DbCommand cmd, DataTable dt)
CancellationToken.ThrowIfCancellationRequested();

if(CancellationToken.CanBeCanceled)
dt.RowChanged += ThrowIfCancelled;
dt.RowChanged += ThrowIfCancelled;

da.Fill(dt);
CancellationToken.ThrowIfCancellationRequested();
Expand Down
8 changes: 4 additions & 4 deletions FAnsiSql/Discovery/DiscoveredDataType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override string ToString()
public void Resize(int newSize, IManagedTransaction managedTransaction = null)
{
var toReplace = GetLengthIfString();

if(newSize == toReplace)
return;

Expand Down Expand Up @@ -126,11 +126,11 @@ public void Resize(int numberOfDigitsBeforeDecimalPoint, int numberOfDigitsAfter

if (toReplace.NumbersAfterDecimalPlace> numberOfDigitsAfterDecimalPoint)
throw new InvalidResizeException(string.Format(FAnsiStrings.DiscoveredDataType_Resize_Cannot_shrink_column__number_of_digits_after_the_decimal_point_is_currently__0__and_you_asked_to_set_it_to__1___Current_SQLType_is__2__, toReplace.NumbersAfterDecimalPlace, numberOfDigitsAfterDecimalPoint, SQLType));

var newDataType = Column.Table.GetQuerySyntaxHelper()
.TypeTranslater.GetSQLDBTypeForCSharpType(new DatabaseTypeRequest(typeof (decimal), null,
new DecimalSize(numberOfDigitsBeforeDecimalPoint, numberOfDigitsAfterDecimalPoint)));

AlterTypeTo(newDataType, managedTransaction);
}

Expand Down Expand Up @@ -164,7 +164,7 @@ public void AlterTypeTo(string newType, IManagedTransaction managedTransaction =
}
}

SQLType = newType;
SQLType = newType;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion FAnsiSql/Discovery/DiscoveredDatabaseHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
namespace FAnsi.Discovery;

/// <summary>
/// DBMS specific implementation of all functionality that relates to interacting with existing databases (dropping databases, creating tables, finding stored proceedures etc). For
/// DBMS specific implementation of all functionality that relates to interacting with existing databases (dropping databases, creating tables, finding stored procedures etc). For
/// database creation see <see cref="DiscoveredServerHelper"/>
/// </summary>
public abstract class DiscoveredDatabaseHelper:IDiscoveredDatabaseHelper
Expand Down
12 changes: 10 additions & 2 deletions FAnsiSql/Discovery/DiscoveredServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,23 @@ public DiscoveredDatabase ExpectDatabase(string database)
/// <param name="timeoutInMillis"></param>
/// <exception cref="TimeoutException"></exception>
/// <exception cref="AggregateException"></exception>
public void TestConnection(int timeoutInMillis = 3000)
public void TestConnection(int timeoutInMillis = 10000)
{
using var con = Helper.GetConnection(Builder);
using(var tokenSource = new CancellationTokenSource(timeoutInMillis))
using (var openTask = con.OpenAsync(tokenSource.Token))
{
try
{
openTask.Wait(tokenSource.Token);
openTask.Wait(timeoutInMillis, tokenSource.Token);
}
catch (OperationCanceledException e)
{
throw new TimeoutException(
string.Format(
FAnsiStrings
.DiscoveredServer_TestConnection_Could_not_connect_to_server___0___after_timeout_of__1__milliseconds_,
Name, timeoutInMillis), e);
}
catch (AggregateException e)
{
Expand Down
20 changes: 10 additions & 10 deletions FAnsiSql/Discovery/TypeTranslation/TypeTranslater.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ public string GetSQLDBTypeForCSharpType(DatabaseTypeRequest request)

if (t == typeof(byte))
return GetByteDataType();

if (t == typeof(short) || t == typeof(short) || t == typeof(ushort) || t == typeof(short?) || t == typeof(ushort?))
return GetSmallIntDataType();

if (t == typeof(int) || t == typeof(int) || t == typeof(uint) || t == typeof(int?) || t == typeof(uint?))
return GetIntDataType();

if (t == typeof (long) || t == typeof(ulong) || t == typeof(long?) || t == typeof(ulong?))
return GetBigIntDataType();

Expand All @@ -80,7 +80,7 @@ public string GetSQLDBTypeForCSharpType(DatabaseTypeRequest request)

if (t == typeof(TimeSpan) || t == typeof(TimeSpan?))
return GetTimeDataType();

if (t == typeof (byte[]))
return GetByteArrayDataType();

Expand Down Expand Up @@ -120,7 +120,7 @@ protected string GetStringDataType(int? maxExpectedStringWidth)

if (maxExpectedStringWidth > MaxStringWidthBeforeMax)
return GetStringDataTypeWithUnlimitedWidth();

return GetStringDataTypeImpl(maxExpectedStringWidth.Value);
}

Expand All @@ -139,7 +139,7 @@ private string GetUnicodeStringDataType(int? maxExpectedStringWidth)

if (maxExpectedStringWidth > MaxStringWidthBeforeMax)
return GetUnicodeStringDataTypeWithUnlimitedWidth();

return GetUnicodeStringDataTypeImpl(maxExpectedStringWidth.Value);
}

Expand Down Expand Up @@ -259,13 +259,13 @@ public DbType GetDbTypeForSQLDBType(string sqlType)

if (IsString(sqlType))
return DbType.String;

if (IsDate(sqlType))
return DbType.DateTime;

if (IsTime(sqlType))
return DbType.Time;

if (IsByteArray(sqlType))
return DbType.Object;

Expand Down Expand Up @@ -295,7 +295,7 @@ public virtual DatabaseTypeRequest GetDataTypeRequestForSQLDBType(string sqlType

if (cSharpType == typeof(TimeSpan))
lengthIfString = GetStringLengthForTimeSpan();

var request = new DatabaseTypeRequest(cSharpType, lengthIfString, digits);

if (cSharpType == typeof(string))
Expand Down Expand Up @@ -377,7 +377,7 @@ public string TranslateSQLDBType(string sqlType, ITypeTranslater destinationType


/// <summary>
/// Return the number of characters required to not truncate/loose any data when altering a column from time (e.g. TIME etc) to varchar(x). Return
/// Return the number of characters required to not truncate/lose any data when altering a column from time (e.g. TIME etc) to varchar(x). Return
/// x such that the column does not loose integrity. This is needed when dynamically discovering what size to make a column by streaming data into a table.
/// if we see many times and nulls we will decide to use a time column then we see strings and have to convert the column to a varchar column without loosing the
/// currently loaded data.
Expand Down Expand Up @@ -409,7 +409,7 @@ select LEN(dt) from omgTimes

/// <summary>
/// Return the number of characters required to not truncate/loose any data when altering a column from datetime (e.g. datetime2, DATE etc) to varchar(x). Return
/// x such that the column does not loose integrity. This is needed when dynamically discovering what size to make a column by streaming data into a table.
/// x such that the column does not lose integrity. This is needed when dynamically discovering what size to make a column by streaming data into a table.
/// if we see many dates and nulls we will decide to use a date column then we see strings and have to convert the column to a varchar column without loosing the
/// currently loaded data.
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions FAnsiSql/FAnsi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="MySqlConnector" Version="2.2.6" />
<PackageReference Include="MySqlConnector" Version="2.2.7" />
<PackageReference Include="Npgsql" Version="7.0.4" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.100" />
<PackageReference Include="Oracle.ManagedDataAccess.Core" Version="3.21.110" />
</ItemGroup>
<ItemGroup>
<Compile Update="FAnsiStrings.Designer.cs">
Expand Down
6 changes: 3 additions & 3 deletions SharedAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyVersion("3.1.0")]
[assembly: AssemblyFileVersion("3.1.0")]
[assembly: AssemblyInformationalVersion("3.1.0")]
[assembly: AssemblyVersion("3.1.1")]
[assembly: AssemblyFileVersion("3.1.1")]
[assembly: AssemblyInformationalVersion("3.1.1")]
34 changes: 17 additions & 17 deletions Tests/FAnsiTests/CrossPlatformTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void DateColumnTests_NoTime(DatabaseType type, object input)
var tbl = db.CreateTable("MyTable",new []{new DatabaseColumnRequest("MyDate",new DatabaseTypeRequest(typeof(DateTime)))});

tbl.Insert(new Dictionary<string, object> { { "MyDate", input } });

using (var blk = tbl.BeginBulkInsert())
{
using var dt = new DataTable();
Expand Down Expand Up @@ -73,7 +73,7 @@ public void DateColumnTests_UkUsFormat_Explicit(DatabaseType type, object input,

//basic insert
tbl.Insert(new Dictionary<string, object> { { "MyDate", input } },cultureInfo);

//then bulk insert, both need to work
using (var blk = tbl.BeginBulkInsert(cultureInfo))
{
Expand Down Expand Up @@ -313,7 +313,7 @@ public void ForeignKeyCreationTest(DatabaseType type)
});

var parentIdPkCol = tblParent.DiscoverColumn("ID");

var parentIdFkCol = new DatabaseColumnRequest("Parent_ID", new DatabaseTypeRequest(typeof (int)));

var tblChild = database.CreateTable("Child", new[]
Expand Down Expand Up @@ -481,10 +481,10 @@ public void CreateMaxVarcharColumns(DatabaseType type)
public void CreateMaxVarcharColumnFromDataTable(DatabaseType type)
{
var database = GetTestDatabase(type);

var dt = new DataTable();
dt.Columns.Add("MassiveColumn");

var sb = new StringBuilder("Amaa");
for (var i = 0; i < 10000; i++)
sb.Append(i);
Expand Down Expand Up @@ -552,7 +552,7 @@ public void AddColumnTest(DatabaseType type,bool useTransaction)
{
tbl.AddColumn(newColumnName, new DatabaseTypeRequest(typeof(DateTime)), true, 1000);
}


//new column should exist
var newCol = tbl.DiscoverColumn(newColumnName);
Expand All @@ -566,7 +566,7 @@ public void AddColumnTest(DatabaseType type,bool useTransaction)

//sql server can't handle altering primary key columns or anything with a foreign key on it too!
if (type == DatabaseType.MicrosoftSQLServer)
fieldsToAlter.Remove("Field1");
fieldsToAlter.Remove("Field1");

foreach (var fieldName in fieldsToAlter)
{
Expand Down Expand Up @@ -679,7 +679,7 @@ public void TestIntDataTypes(DatabaseType type)
Assert.AreEqual(2, size.NumbersAfterDecimalPlace);
Assert.AreEqual(5, size.Precision);
Assert.AreEqual(2, size.Scale);

dt = tbl.GetDataTable();
Assert.AreEqual(1, dt.Rows.OfType<DataRow>().Count(r => Convert.ToDecimal(r[0]) == new decimal(100.0f)));
Assert.AreEqual(1, dt.Rows.OfType<DataRow>().Count(r => Convert.ToDecimal(r[0]) == new decimal(105.0f)));
Expand All @@ -704,7 +704,7 @@ public void TestFloatDataTypes(DatabaseType type)
Assert.AreEqual(1,dt.Rows.OfType<DataRow>().Count(r=>Convert.ToDecimal(r[0]) == new decimal(100.0f)));
Assert.AreEqual(1, dt.Rows.OfType<DataRow>().Count(r => Convert.ToDecimal(r[0]) == new decimal(105.0f)));
Assert.AreEqual(1, dt.Rows.OfType<DataRow>().Count(r => Convert.ToDecimal(r[0]) == new decimal(2.1f)));


var col = tbl.DiscoverColumn("MyCol");
var size = col.DataType.GetDecimalSize();
Expand All @@ -713,7 +713,7 @@ public void TestFloatDataTypes(DatabaseType type)
Assert.AreEqual(1,size.NumbersAfterDecimalPlace);
Assert.AreEqual(4, size.Precision);
Assert.AreEqual(1, size.Scale);

col.DataType.AlterTypeTo("decimal(5,2)");

size = tbl.DiscoverColumn("MyCol").DataType.GetDecimalSize();
Expand All @@ -737,7 +737,7 @@ public void HorribleDatabaseAndTableNames(DatabaseType type,string horribleDatab

database = database.Server.ExpectDatabase(horribleDatabaseName);
database.Create(true);

SqlConnection.ClearAllPools();

try
Expand Down Expand Up @@ -798,7 +798,7 @@ public void HorribleDatabaseAndTableNames(DatabaseType type,string horribleDatab
[TestCase(DatabaseType.PostgreSql, "my.database", "my.table", "my.col")]
public void UnsupportedEntityNames(DatabaseType type, string horribleDatabaseName, string horribleTableName,string columnName)
{

var database = GetTestDatabase(type);

//ExpectDatabase with illegal name
Expand All @@ -812,7 +812,7 @@ public void UnsupportedEntityNames(DatabaseType type, string horribleDatabaseNam
"Table .* contained unsupported .* characters",
Assert.Throws<RuntimeNameException>(()=>database.ExpectTable(horribleTableName))
?.Message);

//CreateTable with illegal name
StringAssert.IsMatch(
"Table .* contained unsupported .* characters",
Expand All @@ -832,7 +832,7 @@ public void UnsupportedEntityNames(DatabaseType type, string horribleDatabaseNam
?.Message);

AssertCanCreateDatabases();

//CreateDatabase with illegal name
StringAssert.IsMatch(
"Database .* contained unsupported .* characters",
Expand Down Expand Up @@ -937,7 +937,7 @@ public void CreateTable_DefaultTest_Date(DatabaseType type)
}
});
DateTime currentValue;

using (var insert = tbl.BeginBulkInsert())
{
using var dt = new DataTable();
Expand All @@ -951,7 +951,7 @@ public void CreateTable_DefaultTest_Date(DatabaseType type)
var dt2 = tbl.GetDataTable();

var databaseValue = (DateTime)dt2.Rows.Cast<DataRow>().Single()["myDt"];

Assert.AreEqual(currentValue.Year,databaseValue.Year);
Assert.AreEqual(currentValue.Month, databaseValue.Month);
Assert.AreEqual(currentValue.Day, databaseValue.Day);
Expand Down Expand Up @@ -1002,7 +1002,7 @@ public void CreateTable_DefaultTest_Guid(DatabaseType type)
var dt2 = tbl.GetDataTable();

var databaseValue = (string)dt2.Rows.Cast<DataRow>().Single()["MyGuid"];

Assert.IsNotNull(databaseValue);
TestContext.WriteLine(databaseValue);
}
Expand Down
Loading

0 comments on commit 8c33145

Please sign in to comment.