Skip to content

Commit 640eb04

Browse files
committed
Merge branch '6.0' into 7.0
# Conflicts: # .github/workflows/dispatched-pgsql9-tests.yml # Orm/Xtensive.Orm/Orm/KeyMapping.cs # Orm/Xtensive.Orm/Orm/Operation.cs # Orm/Xtensive.Orm/Orm/OperationLog.cs # Orm/Xtensive.Orm/Orm/Operations/KeySetOperation.cs
2 parents eac5612 + dd2a21e commit 640eb04

File tree

17 files changed

+148
-65
lines changed

17 files changed

+148
-65
lines changed

Extensions/Xtensive.Orm.Reprocessing/DomainBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Linq;
33
using System.Reflection;
44
using Xtensive.Orm.Configuration;
@@ -27,7 +27,7 @@ public virtual Domain Build(DomainConfiguration config)
2727
var ex = e.InnerException as ReflectionTypeLoadException;
2828
if (ex != null)
2929
throw new InvalidOperationException(
30-
string.Join("\r\n", ex.LoaderExceptions.Select(a => a.Message)), ex);
30+
string.Join(Environment.NewLine, ex.LoaderExceptions.Select(a => a.Message)), ex);
3131
throw;
3232
}
3333
}

Orm/Xtensive.Orm.MySql/Sql.Drivers.MySql/v5_0/Translator.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ public override string DdlStatementDelimiter
3636
get { return ";"; }
3737
}
3838

39-
public override string BatchItemDelimiter
40-
{
41-
get { return ";\r\n"; }
42-
}
39+
public override string NewLine => Environment.NewLine;
4340

4441
public override void Initialize()
4542
{

Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Translator.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ public override void Initialize()
4444
}
4545

4646
public override string DdlStatementDelimiter { get { return ";"; } }
47-
public override string BatchItemDelimiter { get { return ";\r\n"; } }
4847

4948
[DebuggerStepThrough]
5049
public override string QuoteIdentifier(params string[] names)

Orm/Xtensive.Orm.Sqlite/Sql.Drivers.Sqlite/v3/Translator.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,6 @@ public override string DdlStatementDelimiter
4242
get { return ";"; }
4343
}
4444

45-
/// <inheritdoc/>
46-
public override string BatchItemDelimiter
47-
{
48-
get { return ";\r\n"; }
49-
}
50-
5145
/// <inheritdoc/>
5246
public override void Initialize()
5347
{

Orm/Xtensive.Orm.Tests/Issues/IssueJira0786_SqlServerAggregatesProblem/MaxProcessingTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3005,7 +3005,7 @@ public void NullableDoubleFieldExpressionTest01()
30053005
using (var tx = session.OpenTransaction()) {
30063006
var queryableResult = session.Query.All<TestEntity>().Max(i => i.NullableDoubleValue1 * i.NullableDoubleValue1);
30073007
var enumerableResult = session.Query.All<TestEntity>().AsEnumerable().Max(i => i.NullableDoubleValue1 * i.NullableDoubleValue1);
3008-
Assert.That(queryableResult, Is.EqualTo(enumerableResult));
3008+
Assert.That(Math.Abs(queryableResult.Value - enumerableResult.Value), Is.LessThan(DoubleValueAccuracy));
30093009
}
30103010
}
30113011

@@ -3016,7 +3016,7 @@ public void NullableDoubleFieldExpressionTest02()
30163016
using (var tx = session.OpenTransaction()) {
30173017
var queryableResult = session.Query.All<TestEntity>().Max(i => (decimal?) i.NullableDoubleValue1 * i.NullableDecimalValue);
30183018
var enumerableResult = session.Query.All<TestEntity>().AsEnumerable().Max(i => (decimal?) i.NullableDoubleValue1 * i.NullableDecimalValue);
3019-
Assert.That(queryableResult, Is.EqualTo(enumerableResult));
3019+
Assert.That(Math.Abs(queryableResult.Value - enumerableResult.Value), Is.LessThan(DoubleValueAccuracy));
30203020
}
30213021
}
30223022

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using NUnit.Framework;
6+
using Xtensive.Orm.Configuration;
7+
using Xtensive.Orm.Model;
8+
using Xtensive.Orm.Tests.Issues.MysqlStrangeDoubleSemicolumnInCommandIssueModel;
9+
10+
namespace Xtensive.Orm.Tests.Issues.MysqlStrangeDoubleSemicolumnInCommandIssueModel
11+
{
12+
[HierarchyRoot(InheritanceSchema.ClassTable)]
13+
public class Product : Entity
14+
{
15+
[Field, Key]
16+
public long Id { get; set; }
17+
18+
[Field]
19+
public string Name { get; set; }
20+
21+
[Field]
22+
public DateTime CreationDate { get; set; }
23+
24+
[Field]
25+
public Guid UIndentifier { get; set; }
26+
27+
public Product(Session session)
28+
: base(session)
29+
{
30+
}
31+
}
32+
33+
public class DerivedProduct : Product
34+
{
35+
[Field]
36+
public TimeSpan TimeSpan { get; set; }
37+
38+
public DerivedProduct(Session session)
39+
: base(session)
40+
{
41+
}
42+
}
43+
}
44+
45+
namespace Xtensive.Orm.Tests.Issues
46+
{
47+
public sealed class MysqlStrangeDoubleSemicolumnInCommandIssue : AutoBuildTest
48+
{
49+
protected override void CheckRequirements() => Require.ProviderIs(StorageProvider.MySql);
50+
51+
protected override DomainConfiguration BuildConfiguration()
52+
{
53+
var config = base.BuildConfiguration();
54+
config.Types.Register(typeof(Product));
55+
config.Types.Register(typeof(DerivedProduct));
56+
config.UpgradeMode = DomainUpgradeMode.Recreate;
57+
58+
return config;
59+
}
60+
61+
[Test]
62+
public void BatchingTest()
63+
{
64+
using (var session = Domain.OpenSession()) {
65+
session.Events.DbCommandExecuting += BatchingHandler;
66+
using (var transaction = session.OpenTransaction()) {
67+
var product = new Product(session) {
68+
Name = "BatchingTestProduct",
69+
CreationDate = DateTime.UtcNow,
70+
UIndentifier = Guid.NewGuid(),
71+
};
72+
73+
var dProduct = new DerivedProduct(session) {
74+
Name = "BatchingTestDerivedProduct",
75+
CreationDate = DateTime.UtcNow,
76+
UIndentifier = Guid.NewGuid(),
77+
TimeSpan = TimeSpan.FromDays(3)
78+
};
79+
session.SaveChanges(); // split persist and transaction commit
80+
transaction.Complete();
81+
}
82+
session.Events.DbCommandExecuting -= BatchingHandler;
83+
84+
using (var transaction = session.OpenTransaction()) {
85+
var allProducts = session.Query.All<Product>().ToList();
86+
Assert.That(allProducts.Count, Is.EqualTo(2));
87+
88+
var derivedProducts = session.Query.All<DerivedProduct>().ToList();
89+
Assert.That(derivedProducts.Count, Is.EqualTo(1));
90+
}
91+
}
92+
}
93+
94+
private void BatchingHandler(object sender, DbCommandEventArgs e)
95+
{
96+
var commandText = e.Command.CommandText;
97+
if (commandText.Contains("INSERT")) {
98+
var firstInsertIdx = commandText.IndexOf("INSERT", StringComparison.OrdinalIgnoreCase);
99+
var lastInsertIdx = commandText.LastIndexOf("INSERT", StringComparison.OrdinalIgnoreCase);
100+
if (firstInsertIdx == lastInsertIdx) {
101+
throw new Exception("No batching happened");
102+
}
103+
Assert.That(commandText.Contains(";;"), Is.False, $"Command = {commandText}");
104+
}
105+
}
106+
}
107+
}

Orm/Xtensive.Orm.Tests/Linq/MsSamples/LinqToSqlSamples.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ public void DLinqJoin2()
431431
{
432432
var q =
433433
from i in Session.Query.All<Invoice>()
434-
where i.Customer.Address.Country=="USA" && i.Status==InvoiceStatus.Paid
434+
where i.Customer.Address.Country=="United States" && i.Status==InvoiceStatus.Paid
435435
select i;
436436

437437
QueryDumper.Dump(q);

Orm/Xtensive.Orm.Tests/Linq/OrderByTest.cs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -99,34 +99,12 @@ public void OrderByAnonymous2Test()
9999
[Test]
100100
public void OrderByDescendingTest()
101101
{
102-
Require.ProviderIsNot(StorageProvider.Sqlite | StorageProvider.Firebird, "Different ordering");
103-
104-
var result = Session.Query.All<Customer>()
105-
.OrderByDescending(c => c.Address.Country).ThenByDescending(c => c.CustomerId)
106-
.Select(c => c.Address.City)
107-
.AsEnumerable()
108-
.Where(c => c[0] != 'S').ToList();//There are Cites which cause slight deviation in order accross RDBMSs
109-
var expected = Customers
110-
.OrderByDescending(c => c.Address.Country).ThenByDescending(c => c.CustomerId)
111-
.Select(c => c.Address.City)
112-
.Where(c => c[0] != 'S');
113-
Assert.That(result, Is.Not.Empty);
114-
Assert.IsTrue(expected.SequenceEqual(result));
115-
}
116-
117-
[Test]
118-
public void OrderByDescendingAlternativeTest()
119-
{
120-
Require.ProviderIs(StorageProvider.Sqlite | StorageProvider.Firebird, "Different ordering");
121-
122102
var result = Session.Query.All<Customer>()
123-
.Where(c => !c.Address.Country.StartsWith("U"))
124103
.OrderByDescending(c => c.Address.Country).ThenByDescending(c => c.CustomerId)
125104
.Select(c => c.Address.City)
126105
.AsEnumerable()
127106
.Where(c => c[0] != 'S').ToList();//There are Cites which cause slight deviation in order accross RDBMSs
128107
var expected = Customers
129-
.Where(c => !c.Address.Country.StartsWith('U'))
130108
.OrderByDescending(c => c.Address.Country).ThenByDescending(c => c.CustomerId)
131109
.Select(c => c.Address.City)
132110
.Where(c => c[0] != 'S');
@@ -166,12 +144,12 @@ public void OrderByExpressionReducedDataTest()
166144
// to avoid non-english characters, which cause different order
167145
// we filter out everything that may have them
168146
var serverSide = Session.Query.All<Customer>()
169-
.Where(c => c.Address.Country.In("USA", "Canda", "France", "United Kingdom"))
147+
.Where(c => c.Address.Country.In("United States", "Canda", "France", "United Kingdom"))
170148
.OrderBy(c => c.LastName.ToUpper())
171149
.Select(c => new { c.LastName, c.Address.Country })
172150
.ToList();
173151
var local = Customers
174-
.Where(c => c.Address.Country.In("USA", "Canda", "France", "United Kingdom"))
152+
.Where(c => c.Address.Country.In("United States", "Canda", "France", "United Kingdom"))
175153
.OrderBy(c => c.LastName.ToUpper()).Select(c => new { c.LastName, c.Address.Country }).ToList();
176154
Assert.That(serverSide, Is.Not.Empty);
177155
Assert.IsTrue(local.SequenceEqual(serverSide));

Orm/Xtensive.Orm.Tests/Linq/SkipTakeElementAtTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void ReuseTake1Test()
4141
public void TakeTest(int takeValue)
4242
{
4343
var query = Session.Query.All<Customer>()
44-
.Where(c => c.Address.Country == "USA")
44+
.Where(c => c.Address.Country == "United States")
4545
.Select(c => c.Key)
4646
.Take(takeValue);
4747
if (takeValue <= 0) {
@@ -64,9 +64,9 @@ public void TakeTest(int takeValue)
6464
public void SkipTest(int skipValue)
6565
{
6666
var customersFromGermanyOverallCount = Session.Query.All<Customer>()
67-
.Where(c => c.Address.Country == "USA").Count();
67+
.Where(c => c.Address.Country == "United States").Count();
6868
var query = Session.Query.All<Customer>()
69-
.Where(c => c.Address.Country == "USA")
69+
.Where(c => c.Address.Country == "United States")
7070
.Select(c => c.Key)
7171
.Skip(skipValue);
7272

Orm/Xtensive.Orm.Tests/ObjectModel/ChinookDO.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2010 Xtensive LLC.
1+
// Copyright (C) 2010 Xtensive LLC.
22
// All rights reserved.
33
// For conditions of distribution and use, see license.
44
// Created by: Denis Kudelin
@@ -153,7 +153,9 @@ public override void Import(Dictionary<string, object> fields, ImportContext con
153153
StreetAddress = (string) fields["StreetAddress"],
154154
City = (string) fields["City"],
155155
State = (string) fields["State"],
156-
Country = (string) fields["Country"],
156+
// USA and United Kingdom, depending on runtime and/or RDBMS, can be differently ordered
157+
// so not having abbreviation should resolve this issue.
158+
Country = ((string) fields["Country"]).Replace("USA", "United States", StringComparison.Ordinal),
157159
PostalCode = (string) fields["PostalCode"],
158160
},
159161
Phone = (string) fields["Phone"],
@@ -179,7 +181,9 @@ public override void Import(Dictionary<string, object> fields, ImportContext con
179181
StreetAddress = (string) fields["BillingStreetAddress"],
180182
City = (string) fields["BillingCity"],
181183
State = (string) fields["BillingState"],
182-
Country = (string) fields["BillingCountry"],
184+
// USA and United Kingdom, depending on runtime and/or RDBMS, can be differently ordered
185+
// so not having abbreviation should resolve this issue.
186+
Country = ((string) fields["BillingCountry"]).Replace("USA", "United States", StringComparison.Ordinal),
183187
PostalCode = (string) fields["BillingPostalCode"],
184188
},
185189
Total = (decimal) fields["Total"],

0 commit comments

Comments
 (0)