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

Add isUnicode parameter to StringLiteralQueryType function #1192

Merged
merged 3 commits into from
Sep 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,9 @@ protected override Expression VisitSqlConstant(SqlConstantExpression sqlConstant
base.VisitSqlConstant(sqlConstantExpression);
if (shouldExplicitStringLiteralTypes)
{
var isUnicode = FbTypeMappingSource.IsUnicode(sqlConstantExpression.TypeMapping);
Sql.Append(" AS ");
Sql.Append(((IFbSqlGenerationHelper)Dependencies.SqlGenerationHelper).StringLiteralQueryType(sqlConstantExpression.Value as string));
Sql.Append(((IFbSqlGenerationHelper)Dependencies.SqlGenerationHelper).StringLiteralQueryType(sqlConstantExpression.Value as string, isUnicode));
Sql.Append(")");
}
return sqlConstantExpression;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ public FbSqlGenerationHelper(RelationalSqlGenerationHelperDependencies dependenc
: base(dependencies)
{ }

public virtual string StringLiteralQueryType(string s)
public virtual string StringLiteralQueryType(string s, bool isUnicode = true)
{
var length = MinimumStringQueryTypeLength(s);
EnsureStringLiteralQueryTypeLength(length);
return $"VARCHAR({length}) CHARACTER SET UTF8";
var charset = isUnicode ? " CHARACTER SET UTF8" : string.Empty;
return $"VARCHAR({length}){charset}";
}

public virtual string StringParameterQueryType(bool isUnicode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;

public interface IFbSqlGenerationHelper : ISqlGenerationHelper
{
string StringLiteralQueryType(string s);
string StringLiteralQueryType(string s, bool isUnicode);
string StringParameterQueryType(bool isUnicode);
void GenerateBlockParameterName(StringBuilder builder, string name);
string AlternativeStatementTerminator { get; }
Expand Down