|
25 | 25 | namespace Tests.DataProvider |
26 | 26 | { |
27 | 27 | using System.Diagnostics.CodeAnalysis; |
| 28 | + using System.Threading; |
| 29 | + using System.Threading.Tasks; |
| 30 | + using LinqToDB.Data.RetryPolicy; |
28 | 31 | using LinqToDB.Linq; |
29 | 32 | using LinqToDB.SchemaProvider; |
30 | 33 | using Model; |
@@ -2873,5 +2876,45 @@ void AssertColumn(string name, string dbType, int? length) |
2873 | 2876 | } |
2874 | 2877 | } |
2875 | 2878 | } |
| 2879 | + |
| 2880 | + #region Issue 2342 |
| 2881 | + [Test] |
| 2882 | + public void Issue2342Test([IncludeDataSources(false, TestProvName.AllOracle)] string context) |
| 2883 | + { |
| 2884 | + var oldMode = OracleTools.UseAlternativeBulkCopy; |
| 2885 | + try |
| 2886 | + { |
| 2887 | + OracleTools.UseAlternativeBulkCopy = AlternativeBulkCopy.InsertInto; |
| 2888 | + Configuration.RetryPolicy.Factory = connection => new DummyRetryPolicy(); |
| 2889 | + |
| 2890 | + using (var db = new TestDataConnection(context)) |
| 2891 | + using (var table = db.CreateTempTable<Issue2342Entity>()) |
| 2892 | + using (db.BeginTransaction()) |
| 2893 | + { |
| 2894 | + table.BulkCopy(Enumerable.Range(1, 10).Select(id => new Issue2342Entity { Id = id, Name = $"Name_{id}" })); |
| 2895 | + } |
| 2896 | + } |
| 2897 | + finally |
| 2898 | + { |
| 2899 | + OracleTools.UseAlternativeBulkCopy = oldMode; |
| 2900 | + Configuration.RetryPolicy.Factory = null; |
| 2901 | + } |
| 2902 | + } |
| 2903 | + |
| 2904 | + sealed class DummyRetryPolicy : IRetryPolicy |
| 2905 | + { |
| 2906 | + public TResult Execute<TResult>(Func<TResult> operation) => operation(); |
| 2907 | + public void Execute(Action operation) => operation(); |
| 2908 | + public Task<TResult> ExecuteAsync<TResult>(Func<CancellationToken, Task<TResult>> operation, CancellationToken cancellationToken = new CancellationToken()) => operation(cancellationToken); |
| 2909 | + public Task ExecuteAsync(Func<CancellationToken, Task> operation, CancellationToken cancellationToken = new CancellationToken()) => operation(cancellationToken); |
| 2910 | + } |
| 2911 | + |
| 2912 | + [Table] |
| 2913 | + sealed class Issue2342Entity |
| 2914 | + { |
| 2915 | + [Column] public long Id { get; set; } |
| 2916 | + [NotNull, Column(Length = 256)] public string Name { get; set; } = null!; |
| 2917 | + } |
| 2918 | + #endregion |
2876 | 2919 | } |
2877 | 2920 | } |
0 commit comments