Skip to content

Convert SqlCompilerConfiguration to readonly struct #389

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

Merged
merged 2 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
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: 5 additions & 5 deletions Orm/Xtensive.Orm/Sql/Compiler/SqlCompilerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,30 @@ namespace Xtensive.Sql.Compiler
/// <summary>
/// A various options for <see cref="SqlCompiler"/>.
/// </summary>
public sealed class SqlCompilerConfiguration
public readonly struct SqlCompilerConfiguration()
{
/// <summary>
/// Gets or sets the parameter prefix.
/// </summary>
public string ParameterNamePrefix { get; set; }
public string ParameterNamePrefix { get; init; }

/// <summary>
/// Always use database-qualified objects in generated SQL.
/// This option could be enabled if and only if
/// server supports <see cref="QueryFeatures.MultidatabaseQueries"/>.
/// </summary>
public bool DatabaseQualifiedObjects { get; set; }
public bool DatabaseQualifiedObjects { get; init; }

/// <summary>
/// Insert Placeholder nodes instead of real schema names
/// Allows to share compiled query over multiple schemas.
/// </summary>
public bool ParametrizeSchemaNames { get; set; }
public bool ParametrizeSchemaNames { get; init; }

/// <summary>
/// Gets or sets comment location.
/// </summary>
public SqlCommentLocation CommentLocation { get; set; } = SqlCommentLocation.Nowhere;
public SqlCommentLocation CommentLocation { get; init; } = SqlCommentLocation.Nowhere;

/// <summary>
/// Clones this instance.
Expand Down
6 changes: 2 additions & 4 deletions Orm/Xtensive.Orm/Sql/SqlDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,8 @@ public SqlCompilationResult Compile(ISqlCompileUnit statement)
/// <param name="configuration">The options of compilation.</param>
/// <param name="typeIdRegistry">TypeId registry.</param>
/// <returns>Result of compilation.</returns>
public SqlCompilationResult Compile(ISqlCompileUnit statement, SqlCompilerConfiguration configuration, TypeIdRegistry typeIdRegistry = null)
public SqlCompilationResult Compile(ISqlCompileUnit statement, in SqlCompilerConfiguration configuration, TypeIdRegistry typeIdRegistry = null)
{
ArgumentNullException.ThrowIfNull(statement);
ArgumentNullException.ThrowIfNull(configuration);
ValidateCompilerConfiguration(configuration);
return CreateCompiler().Compile(statement, configuration);
}
Expand Down Expand Up @@ -471,7 +469,7 @@ private async Task<Extractor> BuildExtractorAsync(SqlConnection connection, Canc
return extractor;
}

private void ValidateCompilerConfiguration(SqlCompilerConfiguration configuration)
private void ValidateCompilerConfiguration(in SqlCompilerConfiguration configuration)
{
var supported = ServerInfo.Query.Features.Supports(QueryFeatures.MultidatabaseQueries);
var requested = configuration.DatabaseQualifiedObjects;
Expand Down