Skip to content

Commit bcd087d

Browse files
committed
Merge branch '6.0' into merge-to-master
# Conflicts: # Extensions/Xtensive.Orm.BulkOperations/Internals/Operation.cs # Extensions/Xtensive.Orm.BulkOperations/Internals/QueryOperation.cs # Orm/Xtensive.Orm.Firebird/Xtensive.Orm.Firebird.csproj # Orm/Xtensive.Orm.MySql/Xtensive.Orm.MySql.csproj # Orm/Xtensive.Orm.PostgreSql/Orm.Providers.PostgreSql/SqlCompiler.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/Connection.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/DriverFactory.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v10_0/Extractor.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Extractor.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_0/Translator.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_1/Extractor.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_2/Extractor.cs # Orm/Xtensive.Orm.PostgreSql/Sql.Drivers.PostgreSql/v8_3/Extractor.cs # Orm/Xtensive.Orm.SqlServer/Orm.Providers.SqlServer/SqlCompiler.cs # Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/Connection.cs # Orm/Xtensive.Orm.SqlServer/Sql.Drivers.SqlServer/DriverFactory.cs # Orm/Xtensive.Orm.Sqlite/Xtensive.Orm.Sqlite.csproj # Orm/Xtensive.Orm.Tests/Linq/FreeTextTest.cs # Orm/Xtensive.Orm.Tests/Upgrade/UpgradeContextTest.cs # Orm/Xtensive.Orm.Tests/Upgrade/UpgradeDateTimeOffsetTest.cs # Orm/Xtensive.Orm/Core/Extensions/CollectionExtensions.cs # Orm/Xtensive.Orm/Core/Extensions/EnumerableExtensions.cs # Orm/Xtensive.Orm/Core/Scope.cs # Orm/Xtensive.Orm/Modelling/Comparison/Upgrader.cs # Orm/Xtensive.Orm/Orm/Building/Builders/TypeBuilder.cs # Orm/Xtensive.Orm/Orm/Entity.cs # Orm/Xtensive.Orm/Orm/Internals/CompiledQueryRunner.cs # Orm/Xtensive.Orm/Orm/Linq/Expressions/Visitors/IncludeFilterMappingGatherer.cs # Orm/Xtensive.Orm/Orm/Linq/LocalCollectionKeyTypeExtractor.cs # Orm/Xtensive.Orm/Orm/Linq/Translator.Expressions.cs # Orm/Xtensive.Orm/Orm/Linq/Translator.Queryable.cs # Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/BatchingCommandProcessor.cs # Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/Command.cs # Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/CommandProcessorContext.cs # Orm/Xtensive.Orm/Orm/Providers/CommandProcessing/SimpleCommandProcessor.cs # Orm/Xtensive.Orm/Orm/Providers/Expressions/MemberCompilers/StringCompilers.cs # Orm/Xtensive.Orm/Orm/Providers/NameBuilder.cs # Orm/Xtensive.Orm/Orm/Providers/ProviderInfo.cs # Orm/Xtensive.Orm/Orm/Providers/SqlCompiler.Paging.cs # Orm/Xtensive.Orm/Orm/Providers/StorageDriver.Operations.cs # Orm/Xtensive.Orm/Orm/Services/DirectPersistentAccessor.cs # Orm/Xtensive.Orm/Orm/Session.QueryTasks.cs # Orm/Xtensive.Orm/Orm/Session.cs # Orm/Xtensive.Orm/Orm/SessionScope.cs # Orm/Xtensive.Orm/Orm/StorageNode.cs # Orm/Xtensive.Orm/Orm/Upgrade/Internals/SqlActionTranslator.cs # Orm/Xtensive.Orm/Sql/Internals/SqlValidator.cs # Orm/Xtensive.Orm/Sql/SqlConnection.cs # Orm/Xtensive.Orm/Strings.resx # Version.props
2 parents 5e0954e + 7d4ade3 commit bcd087d

File tree

224 files changed

+26123
-2875
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

224 files changed

+26123
-2875
lines changed

ChangeLog/6.0.4_Z_Final.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@
33
[main] Domain.OpenSessionAsync() methods can only open a session to default storage node now
44
[main] Introduced StorageNode.OpenSession() and StorageNode.OpenSessionAsync() method sets to open sessions to the node
55
[main] Fixed issue when DirectPersistentAccessor.SetReferenceKey() was unable to set reference for saved Entities
6+
[main] Hints which path became irrelevant during upgrade actions generation no longer cause error
7+
[main] Fixed certain translation issues of interface members usage for non-perstent types initialization within queries
8+
[main] Improved translation of certain subqueries used in LINQ
9+
[main] Ported changes of DO 5.0 which were missing (from 5.0.18 up to 5.0.21)
10+
[postgresql] Retuned support for DateTimeOffsets
11+
[postgresql] Fixed issue when certain DateTimeOffsets operations result couldn't be used for parts extraction e.g. TotalMilliseconds
12+
[bulkoperations] Addressed wrong table alias assignment issue for Bulk Update and Bulk Delete
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using NUnit.Framework;
6+
using TestCommon.Model;
7+
using Xtensive.Orm.BulkOperations.Tests.Issues.WrongAliassesIssue;
8+
using Xtensive.Sql;
9+
10+
namespace Xtensive.Orm.BulkOperations.Tests.Issues
11+
{
12+
public class JoinedTableAsSourceForOperationsCauseWrongAliases : AutoBuildTest
13+
{
14+
[Test]
15+
public void CustomerCase()
16+
{
17+
using (var session = Domain.OpenSession())
18+
using (var tx = session.OpenTransaction()) {
19+
var query = session.Query.All<DowntimeReason>()
20+
.Where(r => r.DowntimeInfo.Record.Equipment.Id == 333);
21+
22+
var queryResult = query.Delete();
23+
}
24+
}
25+
26+
[Test]
27+
public void MultipleKeyTest()
28+
{
29+
using (var session = Domain.OpenSession())
30+
using (var tx = session.OpenTransaction()) {
31+
var query = session.Query.All<DowntimeReason2>()
32+
.Where(r => r.DowntimeInfo.Record.Equipment.Id == 333);
33+
34+
var queryResult = query.Delete();
35+
}
36+
}
37+
}
38+
}
39+
40+
namespace Xtensive.Orm.BulkOperations.Tests.Issues.WrongAliassesIssue
41+
{
42+
[HierarchyRoot]
43+
public class DowntimeReason : Entity
44+
{
45+
[Field, Key]
46+
public int Id { get; private set; }
47+
48+
[Field]
49+
public DowntimeInfo DowntimeInfo { get; set; }
50+
}
51+
52+
[HierarchyRoot]
53+
[KeyGenerator(KeyGeneratorKind.None)]
54+
public class DowntimeReason2 : Entity
55+
{
56+
[Field, Key(0)]
57+
public int Id { get; private set; }
58+
59+
[Field, Key(1)]
60+
public int Id2 { get; private set; }
61+
62+
[Field]
63+
public DowntimeInfo DowntimeInfo { get; set; }
64+
}
65+
66+
[HierarchyRoot]
67+
public class DowntimeInfo : Entity
68+
{
69+
[Field, Key]
70+
public int Id { get; private set; }
71+
72+
[Field]
73+
public Record Record { get; set; }
74+
}
75+
76+
[HierarchyRoot]
77+
public class Record : Entity
78+
{
79+
[Field, Key]
80+
public int Id { get; private set; }
81+
82+
[Field]
83+
public Equipment Equipment { get; set; }
84+
}
85+
86+
[HierarchyRoot]
87+
public class Equipment : Entity
88+
{
89+
[Field, Key]
90+
public int Id { get; private set; }
91+
}
92+
}

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,21 @@ internal abstract class Operation<T>
2222
where T : class, IEntity
2323
{
2424
public readonly QueryProvider QueryProvider;
25+
public readonly QueryBuilder QueryBuilder;
2526
public List<QueryParameterBinding> Bindings;
27+
public SqlTableRef JoinedTableRef;
28+
2629
protected readonly DomainHandler DomainHandler;
2730
protected readonly PrimaryIndexMapping[] PrimaryIndexes;
28-
public readonly QueryBuilder QueryBuilder;
29-
public readonly Session Session;
3031
protected readonly TypeInfo TypeInfo;
31-
public SqlTableRef JoinedTableRef;
32+
33+
public Session Session { get { return QueryBuilder.Session; } }
3234

3335
public int Execute()
3436
{
3537
EnsureTransactionIsStarted();
36-
QueryProvider.Session.SaveChanges();
37-
var value = ExecuteInternal();
38+
Session.SaveChanges();
39+
int value = ExecuteInternal();
3840
DirectStateAccessor.Get(QueryProvider.Session).Invalidate();
3941
return value;
4042
}
@@ -77,15 +79,15 @@ protected Operation(QueryProvider queryProvider)
7779
{
7880
QueryProvider = queryProvider;
7981
var entityType = typeof (T);
80-
Session = queryProvider.Session;
81-
DomainHandler = Session.Domain.Services.Get<DomainHandler>();
82+
var session = queryProvider.Session;
83+
DomainHandler = session.Domain.Services.Get<DomainHandler>();
8284
TypeInfo = GetTypeInfo(entityType);
83-
var mapping = Session.StorageNode.Mapping;
85+
var mapping = session.StorageNode.Mapping;
8486
PrimaryIndexes = TypeInfo.AffectedIndexes
8587
.Where(i => i.IsPrimary)
8688
.Select(i => new PrimaryIndexMapping(i, mapping[i.ReflectedType]))
8789
.ToArray();
88-
QueryBuilder = Session.Services.Get<QueryBuilder>();
90+
QueryBuilder = session.Services.Get<QueryBuilder>();
8991
}
9092
}
9193
}

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
// Copyright (C) 2019-2020 Xtensive LLC.
1+
// Copyright (C) 2019-2020 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

55
using System;
66
using System.Collections.Generic;
77
using System.Linq;
88
using System.Linq.Expressions;
9+
using Xtensive.Core;
910
using Xtensive.Orm.Linq;
1011
using Xtensive.Orm.Model;
1112
using Xtensive.Sql;
@@ -121,7 +122,6 @@ private void JoinWhenQueryHasNoLimitation(SqlStatement statement, SqlSelect sele
121122
JoinedTableRef = sqlTableRef;
122123
return;
123124
}
124-
125125
if (SupportsJoin()) {
126126
JoinViaFrom(statement, select);
127127
}
@@ -138,14 +138,15 @@ private void JoinViaIn(SqlStatement statement, SqlSelect select)
138138
var indexMapping = PrimaryIndexes[0];
139139
var columns = new List<ColumnInfo>();
140140
foreach (var columnInfo in indexMapping.PrimaryIndex.KeyColumns.Keys) {
141-
var s = select.ShallowClone();
141+
var s = (SqlSelect) select.Clone();
142142
foreach (var column in columns) {
143-
var ex = SqlDml.Equals(SqlDml.TableColumn(s.From, column.Name), SqlDml.TableColumn(table, column.Name));
143+
var ex = SqlDml.Equals(s.From.Columns[column.Name], table.Columns[column.Name]);
144144
s.Where = s.Where.IsNullReference() ? ex : SqlDml.And(s.Where, ex);
145145
}
146-
146+
var existingColumns = s.Columns.ToChainedBuffer();
147147
s.Columns.Clear();
148-
s.Columns.Add(SqlDml.TableColumn(s.From, columnInfo.Name));
148+
var columnToAdd = existingColumns.First(c => c.Name.Equals(columnInfo.Name, StringComparison.Ordinal));
149+
s.Columns.Add(columnToAdd);
149150
var @in = SqlDml.In(SqlDml.TableColumn(table, columnInfo.Name), s);
150151
where = where.IsNullReference() ? @in : SqlDml.And(where, @in);
151152
columns.Add(columnInfo);
@@ -183,4 +184,4 @@ private void JoinViaFrom(SqlStatement statement, SqlSelect select)
183184

184185
#endregion
185186
}
186-
}
187+
}

Orm/Xtensive.Orm.Firebird/Sql.Drivers.Firebird/v2_5/ServerInfoProvider.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2011-2020 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Csaba Beer
55
// Created: 2011.01.10
66

@@ -179,6 +179,7 @@ public override QueryInfo GetQueryInfo()
179179
queryInfo.ParameterPrefix = "@";
180180
queryInfo.MaxLength = MaxCharLength;
181181
queryInfo.MaxComparisonOperations = DoNotKnow;
182+
queryInfo.MaxQueryParameterCount = DoNotKnow;
182183
queryInfo.Features =
183184
QueryFeatures.NamedParameters |
184185
QueryFeatures.ParameterPrefix |

Orm/Xtensive.Orm.Firebird/Xtensive.Orm.Firebird.csproj

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<IsPackable>true</IsPackable>
44
<OutputPath>$(SolutionDir)_Build\$(Configuration)\lib\</OutputPath>
@@ -21,5 +21,11 @@
2121
<ItemGroup>
2222
<ProjectReference Include="..\Xtensive.Orm\Xtensive.Orm.csproj" />
2323
</ItemGroup>
24-
24+
<ItemGroup>
25+
<Compile Update="Sql.Drivers.Firebird\Resources\Strings.Designer.cs">
26+
<DesignTime>True</DesignTime>
27+
<AutoGen>True</AutoGen>
28+
<DependentUpon>Strings.resx</DependentUpon>
29+
</Compile>
30+
</ItemGroup>
2531
</Project>

Orm/Xtensive.Orm.Manual/DomainAndSession/DomainAndSessionSample.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2020 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alex Kofman
55
// Created: 2009.06.17
66

Orm/Xtensive.Orm.Manual/ModellingDomain/AuditAndOpenGenericsTest.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// Copyright (C) 2003-2010 Xtensive LLC.
2-
// All rights reserved.
3-
// For conditions of distribution and use, see license.
1+
// Copyright (C) 2009-2020 Xtensive LLC.
2+
// This code is distributed under MIT license terms.
3+
// See the License.txt file in the project root for more information.
44
// Created by: Alex Kofman
55
// Created: 2009.06.17
66

@@ -236,7 +236,7 @@ public void OnBuilt(Domain domain)
236236
Domain = domain;
237237
domain.SessionOpen += (source, args) => {
238238
args.Session.Events.TransactionOpened += TransactionOpened;
239-
args.Session.Events.TransactionCommitting += TransactionCommitting;
239+
args.Session.Events.TransactionPrecommitting += TransactionPrecommitting;
240240
args.Session.Events.EntityCreated += (sender, e) => EntityEvent(sender, e, true);
241241
args.Session.Events.EntityRemoveCompleted += (sender, e) => EntityEvent(sender, e, false);
242242
args.Session.Events.EntityFieldValueSetCompleted += (sender, e) => EntityEvent(sender, e, false);
@@ -257,7 +257,7 @@ private void TransactionOpened(object sender, TransactionEventArgs e)
257257
session.Extensions.Set(info);
258258
}
259259

260-
private void TransactionCommitting(object sender, TransactionEventArgs e)
260+
private void TransactionPrecommitting(object sender, TransactionEventArgs e)
261261
{
262262
var transaction = e.Transaction;
263263
if (transaction.IsNested)

0 commit comments

Comments
 (0)