File tree Expand file tree Collapse file tree 3 files changed +24
-8
lines changed
FirebirdSql.EntityFrameworkCore.Firebird.Tests/Migrations
FirebirdSql.EntityFrameworkCore.Firebird Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -122,8 +122,8 @@ public void CreateTable()
122122 ""Id_Sequence"" INTEGER NOT NULL,
123123 ""EmployerId"" INTEGER,
124124 ""SSN"" char(11),
125- ""DEF_O"" VARCHAR(20) DEFAULT CAST( _UTF8'test' as VARCHAR(4) CHARACTER SET UTF8) ,
126- ""DEF_S"" VARCHAR(20) DEFAULT ( 'x') ,
125+ ""DEF_O"" VARCHAR(20) DEFAULT _UTF8'test',
126+ ""DEF_S"" VARCHAR(20) DEFAULT 'x',
127127 PRIMARY KEY (""Id""),
128128 UNIQUE (""SSN""),
129129 FOREIGN KEY (""EmployerId"") REFERENCES ""Companies"" (""Id"") ON UPDATE NO ACTION ON DELETE NO ACTION
Original file line number Diff line number Diff line change 1313 * All Rights Reserved.
1414 */
1515
16- //$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)
16+ //$Authors = Jiri Cincura (jiri@cincura.net)
1717
1818using System . Linq ;
1919using System . Linq . Expressions ;
@@ -170,6 +170,24 @@ protected override string GenerateOperator(Expression expression)
170170 return base . GenerateOperator ( expression ) ;
171171 }
172172
173+ protected override Expression VisitConstant ( ConstantExpression constantExpression )
174+ {
175+ var svalue = constantExpression . Value as string ;
176+ var isVarcharHack = constantExpression . Type == typeof ( string ) && svalue ? . Length > 0 ;
177+ if ( isVarcharHack )
178+ {
179+ Sql . Append ( "CAST(" ) ;
180+ }
181+ base . VisitConstant ( constantExpression ) ;
182+ if ( isVarcharHack )
183+ {
184+ Sql . Append ( " AS VARCHAR(" ) ;
185+ Sql . Append ( svalue . Length ) ;
186+ Sql . Append ( ") CHARACTER SET UTF8)" ) ;
187+ }
188+ return constantExpression ;
189+ }
190+
173191 public virtual Expression VisitSubstring ( FbSubstringExpression substringExpression )
174192 {
175193 Sql . Append ( "SUBSTRING(" ) ;
Original file line number Diff line number Diff line change 1313 * All Rights Reserved.
1414 */
1515
16- //$Authors = Jiri Cincura (jiri@cincura.net), Jean Ressouche, Rafael Almeida (ralms@ralms.net)
16+ //$Authors = Jiri Cincura (jiri@cincura.net)
1717
1818using System . Data . Common ;
1919using FirebirdSql . Data . FirebirdClient ;
@@ -39,11 +39,9 @@ protected override void ConfigureParameter(DbParameter parameter)
3939 protected override string GenerateNonNullSqlLiteral ( object value )
4040 {
4141 var svalue = ( string ) value ;
42- if ( svalue == string . Empty )
43- return "''" ;
4442 return IsUnicode
45- ? $ "CAST( _UTF8'{ EscapeSqlLiteral ( svalue ) } ' as VARCHAR( { svalue . Length } ) CHARACTER SET UTF8) "
46- : $ "CAST( '{ EscapeSqlLiteral ( svalue ) } ' as VARCHAR( { svalue . Length } )) ";
43+ ? $ "_UTF8'{ EscapeSqlLiteral ( svalue ) } '"
44+ : $ "'{ EscapeSqlLiteral ( svalue ) } '";
4745 }
4846 }
4947}
You can’t perform that action at this time.
0 commit comments