Skip to content

Commit fc59db7

Browse files
committed
Add isUnicode parameter to StringLiteralQueryType function
1 parent 4d174f3 commit fc59db7

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/FirebirdSql.EntityFrameworkCore.Firebird/Query/Internal/FbQuerySqlGenerator.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,9 @@ protected override Expression VisitSqlConstant(SqlConstantExpression sqlConstant
191191
base.VisitSqlConstant(sqlConstantExpression);
192192
if (shouldExplicitStringLiteralTypes)
193193
{
194+
var isUnicode = FbTypeMappingSource.IsUnicode(sqlConstantExpression.TypeMapping);
194195
Sql.Append(" AS ");
195-
Sql.Append(((IFbSqlGenerationHelper)Dependencies.SqlGenerationHelper).StringLiteralQueryType(sqlConstantExpression.Value as string));
196+
Sql.Append(((IFbSqlGenerationHelper)Dependencies.SqlGenerationHelper).StringLiteralQueryType(sqlConstantExpression.Value as string, isUnicode));
196197
Sql.Append(")");
197198
}
198199
return sqlConstantExpression;

src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/FbSqlGenerationHelper.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,15 @@ public FbSqlGenerationHelper(RelationalSqlGenerationHelperDependencies dependenc
2727
: base(dependencies)
2828
{ }
2929

30-
public virtual string StringLiteralQueryType(string s)
30+
public virtual string StringLiteralQueryType(string s, bool isUnicode = true)
3131
{
3232
var length = MinimumStringQueryTypeLength(s);
3333
EnsureStringLiteralQueryTypeLength(length);
34-
return $"VARCHAR({length}) CHARACTER SET UTF8";
34+
if(isUnicode)
35+
{
36+
return $"VARCHAR({length}) CHARACTER SET UTF8";
37+
}
38+
return $"VARCHAR({length})";
3539
}
3640

3741
public virtual string StringParameterQueryType(bool isUnicode)

src/FirebirdSql.EntityFrameworkCore.Firebird/Storage/Internal/IFbSqlGenerationHelper.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace FirebirdSql.EntityFrameworkCore.Firebird.Storage.Internal;
2222

2323
public interface IFbSqlGenerationHelper : ISqlGenerationHelper
2424
{
25-
string StringLiteralQueryType(string s);
25+
string StringLiteralQueryType(string s, bool isUnicode);
2626
string StringParameterQueryType(bool isUnicode);
2727
void GenerateBlockParameterName(StringBuilder builder, string name);
2828
string AlternativeStatementTerminator { get; }

0 commit comments

Comments
 (0)