Skip to content

Commit

Permalink
Add isUnicode parameter to StringLiteralQueryType function (#1192)
Browse files Browse the repository at this point in the history
  • Loading branch information
gilsonjoanelo authored Sep 26, 2024
1 parent 4d174f3 commit 795b51b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
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

0 comments on commit 795b51b

Please sign in to comment.