Skip to content

Commit

Permalink
Merge pull request #466 from TortugaResearch/Chain4.1
Browse files Browse the repository at this point in the history
Chain4.1
  • Loading branch information
Grauenwolf authored Jul 5, 2022
2 parents b4b48ba + 7fef961 commit 4ce30d5
Show file tree
Hide file tree
Showing 524 changed files with 37,672 additions and 50,443 deletions.
62 changes: 62 additions & 0 deletions Tortuga.Chain/Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,65 @@
## Version 4.1


### Features with Breaking Changes

[#440 Default Sorting for WithLimits](https://github.com/TortugaResearch/Chain/issues/440)

If you use WithLimits without a sort order, then it will act non-deterministically. This is because the database could sort the results in any random order if not constrained.

The fix is to default to sorting with primary key when using WithLimits. If there are no primary keys and no explicit sorting, then an exception will be thrown if in strict mode.

This change also affects table-valued functions. Except these cannot infer the sort order as they do not have a primary key.

For reflection-based scenarios, the method `TableOrViewMetadata<TObjectName, TDbType>.GetDefaultSortOrder(int)` can be used to get a table's default sort order.

### Features

[#459 Add TimeSpan support for Access and OleDB](https://github.com/TortugaResearch/Tortuga.Chain/issues/459)


Access doesn't understand TimeSpan at all and treats it as a DateTime.

OleDB for SQL Server is worse. It returns time(7) columns as strings with the column type set to object.


[#445 Add support for DateOnly and TimeOnly](https://github.com/TortugaResearch/Tortuga.Chain/issues/445)

On the parameter builder side, `DateOnly` and `TimeOnly` need to be converted into `DateTime` or `TimeSpan`. Which specific conversion is used depends on the database/driver combination.

On the materializer side, a new class called `MaterializerTypeConverter` will be used. Moving forward, this will handle type conversions from the result set to the object.

The `MaterializerTypeConverter` is owned by a `DatabaseMetadata` object, allowing additional conversions to be registered at runtime.

[#451 Add support for CommitAsync, Save(savepointName), SaveAsync(savepointName), Rollback(savepointName), and RollbackAsync](https://github.com/TortugaResearch/Chain/issues/451)

We are only exposing these for .NET 6 and later.

[#443 GetByKey, UpdateByKey, and DeleteByKey should support System.Int16](https://github.com/TortugaResearch/Chain/issues/443)

This was done to improve support for lookup tables with small keys.

### Bug Fixes

The OleDB version of SQL Server was truncating fractional seconds when the parameter type is `time(n)` and `n>0`. To fix this, we have to force it to use `DateTime/DBTimeStamp` instead of `TimeSpan/DBTime`.

[#465 OleDbSqlServerTableFunction doesn't support sorting with table limits](https://github.com/TortugaResearch/Tortuga.Chain/issues/465)


Using either works, but there is an error if both are used.


### Performance Enhancements

[#439 Use `SqlCommand.EnableOptimizedParameterBinding` in SQL Server MDS.](https://github.com/TortugaResearch/Chain/issues/439)


### Technical Debt

Added test case for command timeout.

Created `ExecutionToken.PopulateCommand` method. This eliminates a lot of copy & past text from the various `Execute`/`ExecuteAsync` methods.

## Version 4.0

### Architecture
Expand Down
21 changes: 21 additions & 0 deletions Tortuga.Chain/Engineering Notes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Generics

When multiple generic parameters are needed, they should always be in this order.


```
<TConnection, TTransaction, TCommand, TParameter, TObjectName, TDbType>
where TConnection : DbConnection
where TTransaction : DbTransaction
where TCommand : DbCommand
where TParameter : DbParameter
where TObjectName : struct
where TDbType : struct
```

When used...

```
<AbstractConnection, AbstractTransaction, AbstractCommand, AbstractParameter, AbstractObjectName, AbstractDbType>
```

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

namespace Traits;



interface ICommandHelper<TObjectName, TDbType> : IDataSource
where TObjectName : struct
where TDbType : struct
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@

namespace Traits;


interface ICommandHelper<TCommand, TParameter, TObjectName, TDbType> : ICommandHelper<TObjectName, TDbType>
where TCommand : DbCommand
where TParameter : DbParameter
where TObjectName : struct
where TDbType : struct
{
List<TParameter> GetParameters(SqlBuilder<TDbType> builder);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@ interface IGetByKeyHelper<TCommand, TParameter, TObjectName, TDbType> : ICommand
where TObjectName : struct
where TDbType : struct
{
SingleRowDbCommandBuilder<TCommand, TParameter> OnGetByKey<TObject, TKey>(TObjectName tableName, ColumnMetadata<TDbType> keyColumn, TKey key)
MultipleRowDbCommandBuilder<TCommand, TParameter> OnGetByKey<TObject, TKey>(TObjectName tableName, ColumnMetadata<TDbType> keyColumn, TKey key)
where TObject : class;

MultipleRowDbCommandBuilder<TCommand, TParameter> OnGetByKeyList<TObject, TKey>(TObjectName tableName, ColumnMetadata<TDbType> keyColumn, IEnumerable<TKey> keys)
where TObject : class;
}
}



}
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using Tortuga.Chain;
using System.Data.Common;
using Tortuga.Chain;
using Tortuga.Chain.DataSources;
using Tortuga.Shipwright;

namespace Traits;

[Trait]
class SupportsDeleteAllTrait<TObjectName, TDbType> : ISupportsDeleteAll
class SupportsDeleteAllTrait<TParameter, TObjectName, TDbType> : ISupportsDeleteAll
where TObjectName : struct
where TDbType : struct
where TParameter : DbParameter
{
[Partial("tableName")] public Func<TObjectName, ILink<int?>> OnDeleteAll { get; set; } = null!;

Expand All @@ -30,6 +32,5 @@ class SupportsDeleteAllTrait<TObjectName, TDbType> : ISupportsDeleteAll

ILink<int?> ISupportsDeleteAll.DeleteAll(string tableName) => OnDeleteAll(DataSource.DatabaseMetadata.ParseObjectName(tableName));


ILink<int?> ISupportsDeleteAll.DeleteAll<TObject>() => DeleteAll<TObject>();
}
}
Loading

0 comments on commit 4ce30d5

Please sign in to comment.