@@ -54,7 +54,7 @@ public bool HasParenthesesIfNoArguments
54
54
get { return true ; }
55
55
}
56
56
57
- public SqlString Render ( IList args , ISessionFactoryImplementor factory )
57
+ public virtual SqlString Render ( IList args , ISessionFactoryImplementor factory )
58
58
{
59
59
if ( args . Count != 2 )
60
60
{
@@ -87,23 +87,36 @@ public SqlString Render(IList args, ISessionFactoryImplementor factory)
87
87
throw new QueryException ( string . Format ( "invalid Hibernate type for cast(): type {0} not found" , typeName ) ) ;
88
88
}
89
89
90
- if ( CastingIsRequired ( sqlType ) )
91
- {
92
- return new SqlString ( "cast(" , args [ 0 ] , " as " , sqlType , ")" ) ;
93
- }
94
- else
95
- {
90
+ // TODO 6.0: Remove pragma block with its content
91
+ #pragma warning disable 618
92
+ if ( ! CastingIsRequired ( sqlType ) )
96
93
return new SqlString ( "(" , args [ 0 ] , ")" ) ;
97
- }
94
+ #pragma warning restore 618
95
+
96
+ return Render ( args [ 0 ] , sqlType , factory ) ;
98
97
}
99
98
100
99
#endregion
101
100
101
+ // Since v5.3
102
+ [ Obsolete ( "This method has no usages and will be removed in a future version" ) ]
102
103
protected virtual bool CastingIsRequired ( string sqlType )
103
104
{
104
105
return true ;
105
106
}
106
107
108
+ /// <summary>
109
+ /// Renders the SQL fragment representing the SQL cast.
110
+ /// </summary>
111
+ /// <param name="expression">The cast argument.</param>
112
+ /// <param name="sqlType">The SQL type to cast to.</param>
113
+ /// <param name="factory">The session factory.</param>
114
+ /// <returns>A SQL fragment.</returns>
115
+ protected virtual SqlString Render ( object expression , string sqlType , ISessionFactoryImplementor factory )
116
+ {
117
+ return new SqlString ( "cast(" , expression , " as " , sqlType , ")" ) ;
118
+ }
119
+
107
120
#region IFunctionGrammar Members
108
121
109
122
bool IFunctionGrammar . IsSeparator ( string token )
0 commit comments