@@ -153,7 +153,7 @@ public List<DataDictionary> FetchData(string selectSql, bool upperCaseKeys = fal
153153 /// <returns>A string representing the result of the query. If the result is DBNull, an empty string is returned.</returns>
154154 public string ExecuteScalar ( string sqlStatement )
155155 {
156- if ( ! Regex . IsMatch ( sqlStatement , @"^\s*SELECT\s+.*" , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) )
156+ if ( ! Regex . IsMatch ( sqlStatement , Utils . SelectQueryPattern , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) )
157157 throw new QueryDBException ( QueryDBExceptions . ErrorMessage . UnsupportedExecuteScalarCommand ,
158158 QueryDBExceptions . ErrorType . UnsupportedCommand , QueryDBExceptions . AdditionalInfo . UnsupportedExecuteScalarCommand ) ;
159159 var value = string . Empty ;
@@ -200,7 +200,7 @@ public string ExecuteScalar(string sqlStatement)
200200 /// <returns>The result of the query, converted to the specified type. If the result is DBNull, the default value for the type is returned.</returns>
201201 public T ExecuteScalar < T > ( string sqlStatement )
202202 {
203- if ( ! Regex . IsMatch ( sqlStatement , @"^\s*SELECT\s+.*" , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) )
203+ if ( ! Regex . IsMatch ( sqlStatement , Utils . SelectQueryPattern , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) )
204204 throw new QueryDBException ( QueryDBExceptions . ErrorMessage . UnsupportedExecuteScalarCommand ,
205205 QueryDBExceptions . ErrorType . UnsupportedCommand , QueryDBExceptions . AdditionalInfo . UnsupportedExecuteScalarCommand ) ;
206206 var value = default ( T ) ;
@@ -246,7 +246,7 @@ public T ExecuteScalar<T>(string sqlStatement)
246246 /// <returns>The number of rows affected.</returns>
247247 public int ExecuteCommand ( string sqlStatement )
248248 {
249- if ( Regex . IsMatch ( sqlStatement , "^ \\ s*SELECT \\ s+.*" , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) )
249+ if ( Regex . IsMatch ( sqlStatement , Utils . SelectQueryPattern , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) )
250250 throw new QueryDBException ( QueryDBExceptions . ErrorMessage . UnsupportedSelectExecuteCommand ,
251251 QueryDBExceptions . ErrorType . UnsupportedCommand , QueryDBExceptions . AdditionalInfo . UnsupportedSelectExecuteCommand ) ;
252252 if ( Database . Equals ( DB . MSSQL ) )
@@ -294,7 +294,7 @@ public int ExecuteCommand(string sqlStatement)
294294 /// </returns>
295295 public bool ExecuteTransaction ( List < string > sqlStatements )
296296 {
297- var selectExists = sqlStatements . Any ( sqlStatement => Regex . IsMatch ( sqlStatement , "^ \\ s*SELECT \\ s+.*" , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) ) ;
297+ var selectExists = sqlStatements . Any ( sqlStatement => Regex . IsMatch ( sqlStatement , Utils . SelectQueryPattern , RegexOptions . IgnoreCase | RegexOptions . Singleline , TimeSpan . FromSeconds ( 5 ) ) ) ;
298298 if ( selectExists )
299299 throw new QueryDBException ( QueryDBExceptions . ErrorMessage . UnsupportedSelectExecuteTransaction ,
300300 QueryDBExceptions . ErrorType . UnsupportedCommand , QueryDBExceptions . AdditionalInfo . UnsupportedSelectExecuteTransaction ) ;
0 commit comments