Skip to content

Commit aa87bee

Browse files
committed
Merge branch '6.0' into 7.0
# Conflicts: # Extensions/Xtensive.Orm.BulkOperations/Internals/Operation.cs # Orm/Xtensive.Orm/Tuples/Packed/TupleLayout.cs # Version.props
2 parents 94b7043 + 1a82bc0 commit aa87bee

File tree

13 files changed

+1503
-47
lines changed

13 files changed

+1503
-47
lines changed

ChangeLog/6.0.8_Z_Final.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[main] Resolved DateTimeOffset reading issues for certain queries with JOIN
2+
[main] Improved compiled queries work with entity parameters
3+
[main] Coalesce operator with local Entity/Structure instance in it is prohibited to prevent wrong query results
4+
[main] Ternary operator with local Entity/Structure instance in it is prohibited to prevent wrong query results
5+
[bulkoperations] Ressuracted check for transaction to prevent unrollbackable changes

Extensions/Xtensive.Orm.BulkOperations/Internals/Operation.cs

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2019-2020 Xtensive LLC.
1+
// Copyright (C) 2019-2021 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44

@@ -50,11 +50,7 @@ public async Task<int> ExecuteAsync(CancellationToken token = default)
5050
return value;
5151
}
5252

53-
private void EnsureTransactionIsStarted()
54-
{
55-
var accessor = QueryProvider.Session.Services.Demand<DirectSqlAccessor>();
56-
_ = accessor.Transaction;
57-
}
53+
protected void EnsureTransactionIsStarted() => Transaction.Require(QueryProvider.Session);
5854

5955
protected abstract int ExecuteInternal();
6056

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// Copyright (C) 2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
using System.Collections.Generic;
7+
using System.Linq;
8+
using System.Reflection;
9+
using System.Text;
10+
using NUnit.Framework;
11+
using Xtensive.Tuples.Packed;
12+
using Xtensive.Orm.Tests;
13+
14+
namespace Xtensive.Tuples
15+
{
16+
[TestFixture]
17+
public sealed class DateTimeOffsetTupleTest
18+
{
19+
[Test]
20+
public void OnlyDateTimeOffsetFieldsTest()
21+
{
22+
var minLength = 30;
23+
var maxLength = 200;
24+
var iterationCount = 1000;
25+
var rnd = RandomManager.CreateRandom();
26+
var generator = InstanceGeneratorProvider.Default.GetInstanceGenerator<DateTimeOffset>();
27+
for (var i = 0; i < iterationCount; i++) {
28+
var count = rnd.Next(maxLength - minLength);
29+
30+
var fields = new Type[count];
31+
var data = new DateTimeOffset[count];
32+
for (var j = 0; j < count; j++) {
33+
data[j] = generator.GetInstance(rnd);
34+
fields[j] = typeof(DateTimeOffset);
35+
}
36+
37+
// Testing writes (untyped)
38+
var tuple1 = Tuple.Create(fields);
39+
Assert.That(tuple1, Is.InstanceOf<PackedTuple>());
40+
for (var j = 0; j < count; j++)
41+
tuple1.SetValue(j, (object) data[j]);
42+
// Testing reads (untyped)
43+
for (var j = 0; j < count; j++)
44+
Assert.AreEqual(data[j], tuple1.GetValue(j));
45+
46+
// Testing writes (untyped)
47+
var tuple2 = Tuple.Create(fields);
48+
Assert.That(tuple2, Is.InstanceOf<PackedTuple>());
49+
for (var j = 0; j < count; j++)
50+
tuple2.SetValue(j, data[j]);
51+
for (var j = 0; j < count; j++)
52+
Assert.AreEqual(data[j], tuple2.GetValue<DateTimeOffset>(j));
53+
}
54+
}
55+
}
56+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (C) 2021 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
4+
5+
using System;
6+
7+
namespace Xtensive.Orm.Tests
8+
{
9+
[Serializable]
10+
internal class DateTimeOffsetInstanceGenerator : InstanceGeneratorBase<DateTimeOffset>
11+
{
12+
private readonly IInstanceGenerator<DateTime> dateTimeInstanceGenerator;
13+
14+
public override DateTimeOffset GetInstance(Random random)
15+
{
16+
var randomDateTime = dateTimeInstanceGenerator.GetInstance(random);
17+
var randomTimeSpan = new TimeSpan(random.Next(0, 10), random.Next(0, 60), 0);
18+
19+
var signBase = random.Next(-100, 100);
20+
if (signBase != 0 && (signBase / Math.Abs(signBase)) < 0)
21+
randomTimeSpan = randomTimeSpan.Negate();
22+
23+
return new DateTimeOffset(randomDateTime, randomTimeSpan);
24+
}
25+
26+
public DateTimeOffsetInstanceGenerator(IInstanceGeneratorProvider provider)
27+
: base(provider)
28+
{
29+
dateTimeInstanceGenerator = provider.GetInstanceGenerator<DateTime>();
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)