This is an automated email from the ASF dual-hosted git repository. ptupitsyn pushed a commit to branch ignite-22133-bak in repository https://gitbox.apache.org/repos/asf/ignite-3.git
commit 5931ae0dfd5cb32a049ffe98f7438256e51a40db Author: Pavel Tupitsyn <[email protected]> AuthorDate: Fri Jul 11 15:00:05 2025 +0300 Add IgniteRelationalTransactionFactory to disable savepoints --- .../DataCommon/IgniteTransaction.cs | 3 ++ .../IgniteServiceCollectionExtensions.cs | 1 + .../Internal/IgniteRelationalTransaction.cs | 38 ++++++++++++++++++++ .../Internal/IgniteRelationalTransactionFactory.cs | 42 ++++++++++++++++++++++ .../Update/Internal/IgniteUpdateSqlGenerator.cs | 6 ++-- 5 files changed, 86 insertions(+), 4 deletions(-) diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs index 56a4b73bc05..553d282e10d 100644 --- a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs +++ b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/DataCommon/IgniteTransaction.cs @@ -32,6 +32,8 @@ public class IgniteTransaction : DbTransaction public override IsolationLevel IsolationLevel { get; } + public override bool SupportsSavepoints => false; + internal ITransaction InternalTransaction { get; } protected override DbConnection DbConnection { get; } @@ -46,4 +48,5 @@ public class IgniteTransaction : DbTransaction public override async Task RollbackAsync(string savepointName, CancellationToken cancellationToken = default) => await InternalTransaction.RollbackAsync(); + } diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Extensions/IgniteServiceCollectionExtensions.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Extensions/IgniteServiceCollectionExtensions.cs index ae25b5b03eb..9bf1cfb5954 100644 --- a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Extensions/IgniteServiceCollectionExtensions.cs +++ b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Extensions/IgniteServiceCollectionExtensions.cs @@ -77,6 +77,7 @@ public static class IgniteServiceCollectionExtensions .TryAdd<IQueryTranslationPostprocessorFactory, IgniteQueryTranslationPostprocessorFactory>() .TryAdd<IUpdateSqlGenerator, IgniteUpdateSqlGenerator>() .TryAdd<ISqlExpressionFactory, IgniteSqlExpressionFactory>() + .TryAdd<IRelationalTransactionFactory, IgniteRelationalTransactionFactory>() .TryAddProviderSpecificServices( b => b.TryAddScoped<IIgniteRelationalConnection, IgniteRelationalConnection>()); diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Storage/Internal/IgniteRelationalTransaction.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Storage/Internal/IgniteRelationalTransaction.cs new file mode 100644 index 00000000000..6609174d39e --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Storage/Internal/IgniteRelationalTransaction.cs @@ -0,0 +1,38 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Apache.Ignite.EntityFrameworkCore.Storage.Internal; + +using System; +using System.Data.Common; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Storage; + +public class IgniteRelationalTransaction : RelationalTransaction +{ + public IgniteRelationalTransaction( + IRelationalConnection connection, + DbTransaction transaction, + Guid transactionId, + IDiagnosticsLogger<DbLoggerCategory.Database.Transaction> logger, + bool transactionOwned, + ISqlGenerationHelper sqlGenerationHelper) + : base(connection, transaction, transactionId, logger, transactionOwned, sqlGenerationHelper) + { + } + + public override bool SupportsSavepoints => false; +} diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Storage/Internal/IgniteRelationalTransactionFactory.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Storage/Internal/IgniteRelationalTransactionFactory.cs new file mode 100644 index 00000000000..f82e3b31d01 --- /dev/null +++ b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Storage/Internal/IgniteRelationalTransactionFactory.cs @@ -0,0 +1,42 @@ +// Licensed to the Apache Software Foundation (ASF) under one or more +// contributor license agreements. See the NOTICE file distributed with +// this work for additional information regarding copyright ownership. +// The ASF licenses this file to You under the Apache License, Version 2.0 +// (the "License"); you may not use this file except in compliance with +// the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +namespace Apache.Ignite.EntityFrameworkCore.Storage.Internal; + +using System; +using System.Data.Common; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Diagnostics; +using Microsoft.EntityFrameworkCore.Storage; + +public class IgniteRelationalTransactionFactory : IRelationalTransactionFactory +{ + public IgniteRelationalTransactionFactory(RelationalTransactionFactoryDependencies dependencies) + { + Dependencies = dependencies; + } + + protected virtual RelationalTransactionFactoryDependencies Dependencies { get; } + + public RelationalTransaction Create( + IRelationalConnection connection, + DbTransaction transaction, + Guid transactionId, + IDiagnosticsLogger<DbLoggerCategory.Database.Transaction> logger, + bool transactionOwned) + { + return new IgniteRelationalTransaction(connection, transaction, transactionId, logger, transactionOwned, Dependencies.SqlGenerationHelper); + } +} diff --git a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Update/Internal/IgniteUpdateSqlGenerator.cs b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Update/Internal/IgniteUpdateSqlGenerator.cs index cfe9a4638bb..59b3adf3574 100644 --- a/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Update/Internal/IgniteUpdateSqlGenerator.cs +++ b/modules/platforms/dotnet/Apache.Ignite.EntityFrameworkCore/Update/Internal/IgniteUpdateSqlGenerator.cs @@ -34,7 +34,7 @@ public class IgniteUpdateSqlGenerator : UpdateAndSelectSqlGenerator // SqlGenerationHelper.DelimitIdentifier(commandStringBuilder, "rowid"); // commandStringBuilder.Append(" = ").Append("last_insert_rowid()"); - throw new NotSupportedException("Ignite does not support identity columns."); + // TODO: Why do we need this? } protected override ResultSetMapping AppendSelectAffectedCountCommand( @@ -49,9 +49,7 @@ public class IgniteUpdateSqlGenerator : UpdateAndSelectSqlGenerator protected override void AppendRowsAffectedWhereCondition(StringBuilder commandStringBuilder, int expectedRowsAffected) { - Check.NotNull(commandStringBuilder, nameof(commandStringBuilder)); - - throw new NotSupportedException("Ignite does not support affected rows check."); + // TODO: Why do we need this? } public override string GenerateNextSequenceValueOperation(string name, string? schema)
