@@ -27,19 +27,38 @@ public FbSqlGenerationHelper(RelationalSqlGenerationHelperDependencies dependenc
2727 : base ( dependencies )
2828 { }
2929
30- public virtual string StringLiteralQueryType ( string s , bool isUnicode = true , string ? storeTypeNameBase = null , int ? size = null )
30+ public virtual string StringLiteralQueryType ( string s , bool isUnicode = true , string storeTypeNameBase = "" , int size = 0 )
3131 {
32- var length = size ?? MinimumStringQueryTypeLength ( s ) ;
32+ var maxSize = MinimumStringQueryTypeLength ( s ) ;
33+ string typeName ;
34+ if ( storeTypeNameBase . Equals ( "BLOB SUB_TYPE TEXT" , StringComparison . OrdinalIgnoreCase ) )
35+ {
36+ typeName = "VARCHAR" ;
37+ }
38+ else
39+ {
40+ typeName = IsEmpty ( storeTypeNameBase ) ? "VARCHAR" : storeTypeNameBase ;
41+ }
42+
3343 var charset = isUnicode ? " CHARACTER SET UTF8" : string . Empty ;
34- var storeTypeName = storeTypeNameBase ?? "VARCHAR" ;
35- return $ "{ storeTypeName } ({ length } ){ charset } ";
44+ return $ "{ typeName } ({ maxSize } ){ charset } ";
3645 }
3746
38- public virtual string StringParameterQueryType ( bool isUnicode , string ? storeTypeNameBase = null , int ? size = null )
47+ public virtual string StringParameterQueryType ( bool isUnicode , string storeTypeNameBase = "" , int size = 0 )
3948 {
40- var maxSize = size ?? ( isUnicode ? FbTypeMappingSource . UnicodeVarcharMaxSize : FbTypeMappingSource . VarcharMaxSize ) ;
41- var storeTypeName = storeTypeNameBase ?? "VARCHAR" ;
42- return $ "{ storeTypeName } ({ size } )";
49+ int maxSize ;
50+ string typeName ;
51+ if ( storeTypeNameBase . Equals ( "BLOB SUB_TYPE TEXT" , StringComparison . OrdinalIgnoreCase ) )
52+ {
53+ maxSize = ( isUnicode ? FbTypeMappingSource . UnicodeVarcharMaxSize : FbTypeMappingSource . VarcharMaxSize ) ;
54+ typeName = "VARCHAR" ;
55+ }
56+ else
57+ {
58+ maxSize = size > 0 ? size : ( isUnicode ? FbTypeMappingSource . UnicodeVarcharMaxSize : FbTypeMappingSource . VarcharMaxSize ) ;
59+ typeName = IsEmpty ( storeTypeNameBase ) ? "VARCHAR" : storeTypeNameBase ;
60+ }
61+ return $ "{ typeName } ({ maxSize } )";
4362 }
4463
4564 public virtual void GenerateBlockParameterName ( StringBuilder builder , string name )
@@ -49,17 +68,16 @@ public virtual void GenerateBlockParameterName(StringBuilder builder, string nam
4968
5069 public virtual string AlternativeStatementTerminator => "~" ;
5170
52- static int MinimumStringQueryTypeLength ( string s )
71+ private int MinimumStringQueryTypeLength ( string s )
5372 {
5473 var length = s ? . Length ?? 0 ;
5574 if ( length == 0 )
5675 length = 1 ;
5776 return length ;
5877 }
5978
60- static void EnsureStringLiteralQueryTypeLength ( int length )
79+ private bool IsEmpty ( string storeTypeNameBase )
6180 {
62- if ( length > FbTypeMappingSource . UnicodeVarcharMaxSize )
63- throw new ArgumentOutOfRangeException ( nameof ( length ) ) ;
81+ return ( storeTypeNameBase == null || string . IsNullOrEmpty ( storeTypeNameBase ) || string . IsNullOrWhiteSpace ( storeTypeNameBase ) ) ;
6482 }
6583}
0 commit comments