Commits

Inside Zhou committed ac02f55

[bugfix]解析原始sql语句的正则表达式有误,columnTxt应该使用懒惰匹配。

Comments (0)

Files changed (1)

 	public class QueryPlan {
 		public const string Rownum = "_rownum_";
 
-		static Regex _basicSqlRegExp = new Regex(@"
-^\s*
-select
-\s+
-(?<columnTxt>.+)
-\s+
-from
-(?:
-	\s*(?<subQuery>\(.+\))(?:\s*(?<alias>\w+|\""\w+\""))?
-	|
-	\s+(?<relationName>\w+|\""\w+\"")(?:\s+(?<alias>\w+|\""\w+\""))?
-)
-\s*$
-"
-			, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture);
-
 		string _originalSQLTxt;
 		string _relation;
 		string _alias;
 		}
 
 		static DyObj _ParseSql(string sql, SqlHelper sh) {
-			var m = _basicSqlRegExp.Match(sql);
+			var regExp = new Regex(@"
+^\s*
+select
+\s+
+(?<columnTxt>.+?)
+\s+
+from
+(?:
+	\s*(?<subQuery>\(.+\))(?:\s*(?<alias>\w+|\""\w+\""))?
+	|
+	\s+(?<relationName>\w+|\""\w+\"")(?:\s+(?<alias>\w+|\""\w+\""))?
+)
+\s*$
+"
+			, RegexOptions.IgnoreCase | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace | RegexOptions.ExplicitCapture);
+
+			var m = regExp.Match(sql);
 			if(!m.Success) {
 				throw new ArgumentException("无法识别的查询语句。\n" + sql);
 			}