Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removing unused BatchCommand.DefaultBuilderCapacity #584

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/YesSql.Core/Commands/BatchCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ namespace YesSql.Commands
{
public class BatchCommand : IIndexCommand
{
public static int DefaultBuilderCapacity = 10 * 1024;
Copy link
Contributor

@hyzx86 hyzx86 Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a static attribute that allows developers to modify it, to adapt the maximum number of parameters for different databases

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is that this property is never used in any concrete way. It's possible that at some point I actually used a StringBuilder, but this is not the case anymore and the current implementation (string.Concat) is actually better than StringBuilder. So this should be removed. This is a breaking change though and maybe it should be made obsolete instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obsoleted it instead.


public List<string> Queries { get; set; } = new List<string>();
public DbCommand Command { get; set; }
public List<Action<DbDataReader>> Actions = new();
Expand Down Expand Up @@ -54,14 +52,6 @@ public async Task ExecuteAsync(DbConnection connection, DbTransaction transactio
logger.LogTrace(command);
}

if (command.Length > DefaultBuilderCapacity)
{
if (logger.IsEnabled(LogLevel.Warning))
{
logger.LogWarning("The default capacity of the BatchCommand StringBuilder {Default} might not be sufficient. It can be increased with BatchCommand.DefaultBuilderCapacity to at least {Suggested}", DefaultBuilderCapacity, command.Length);
}
}

Command.Transaction = transaction;
Command.CommandText = command;

Expand Down