From: Michael D. <mik...@us...> - 2004-05-20 20:59:29
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5908/NHibernate/Impl Modified Files: SessionImpl.cs Log Message: Added some comments and made a minor mod to AdoHack. Index: SessionImpl.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Impl/SessionImpl.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** SessionImpl.cs 6 May 2004 13:14:02 -0000 1.25 --- SessionImpl.cs 20 May 2004 20:59:19 -0000 1.26 *************** *** 39,42 **** --- 39,72 ---- if (dialect.UseNamedParameters) { + /* + * (?<param>\?) + * Capture to <param> + * ? + * + * "select a,b,c from a=? and b=? and c=?" + * Splitting: select a,b,c from a=? and b=? and c=? + * [0] => select a,b,c from a= + * [1] => ? + * [2] => and b= + * [3] => ? + * [4] => and c= + * [5] => ? + * [6] => + * (?<param>@\w*\b) -> actual string for Ms Sql 2000 Dialect (@=named param prefix + * Capture to <param> + * : + * Any word character + * * (zero or more times) + * Word boundy between //w and //W + * + * takes a string like "select a,b,c from a=@p1 and b=@p2 c='@'" + * and splits it into + * Splitting: select a,b,c from a=@p1 and b=@p2 and c='@' + * [0] => select a,b,c from a= + * [1] => @p1 + * [2] => and b= + * [3] => @p2 + * [4] => and c='@' + */ Regex parser = new Regex("(?<param>" + dialect.NamedParametersPrefix + "\\w*\\b)", RegexOptions.None); //.Compiled); string[] tokens = parser.Split(sql); *************** *** 68,72 **** param = cmd.CreateParameter(); ! param.ParameterName = paramIdx.ToString(); cmd.Parameters.Add(param); paramIdx++; --- 98,102 ---- param = cmd.CreateParameter(); ! param.ParameterName = dialect.UseNamedParameters ? dialect.NamedParametersPrefix + "p" + paramIdx.ToString() : paramIdx.ToString(); cmd.Parameters.Add(param); paramIdx++; *************** *** 78,81 **** --- 108,133 ---- public static void ReplaceHqlParameters(Dialect.Dialect dialect, IDbCommand cmd) { + /* + * (?<param>\[<\w*>\]) + * Capture to <param> + * [< + * Any word character + * *(zero or more times) + * >] + * + * select a,b,c from a=[<parama>] and b=[<paramb>] + * for the life of me I could not figure out why the params would be wrapped + * with a "[<" and ">]" - turns out in Hql.WhereParser.DoTokens one of the original + * developers changed it to that from "?" -> that is what I would prefer to use + * instead of this silly parameter and regexp use... + * + * Splitting: select a,b,c from a=[<parama>] and b=[<paramb>] + * [0] => select a,b,c from a= + * [1] => [<parama>] + * [2] => and b= + * [3] => [<paramb>] + * [4] => + * + */ Regex parser = new Regex("(?<param>\\[<\\w*>\\])", RegexOptions.Compiled); string[] tokens; |