From: Michael D. <mik...@us...> - 2004-12-04 22:41:42
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1955/NHibernate/SqlCommand Modified Files: Parameter.cs QuerySelect.cs Template.cs Log Message: Modified more exceptions to not be "throw e" and instead just be "throw" Moved internal fields from IList to ISet where applicable. Fixed generation of sql from hql that was causing spacing problems with MySql. Index: QuerySelect.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/QuerySelect.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** QuerySelect.cs 22 Nov 2004 03:56:08 -0000 1.2 --- QuerySelect.cs 4 Dec 2004 22:41:30 -0000 1.3 *************** *** 3,6 **** --- 3,8 ---- using System.Collections; + using Iesi.Collections; + using NHibernate.Dialect; using NHibernate.Util; *************** *** 26,58 **** private bool distinct = false; ! private static readonly IList dontSpace = new ArrayList(); static QuerySelect() { //dontSpace.add("'"); ! dontSpace.Add("."); ! dontSpace.Add("+"); ! dontSpace.Add("-"); ! dontSpace.Add("/"); ! dontSpace.Add("*"); ! dontSpace.Add("<"); ! dontSpace.Add(">"); ! dontSpace.Add("="); ! dontSpace.Add("#"); ! dontSpace.Add("~"); ! dontSpace.Add("|"); ! dontSpace.Add("&"); ! dontSpace.Add("<="); ! dontSpace.Add(">="); ! dontSpace.Add("=>"); ! dontSpace.Add("=<"); ! dontSpace.Add("!="); ! dontSpace.Add("<>"); ! dontSpace.Add("!#"); ! dontSpace.Add("!~"); ! dontSpace.Add("!<"); ! dontSpace.Add("!>"); ! dontSpace.Add(StringHelper.OpenParen); //for MySQL ! dontSpace.Add(StringHelper.ClosedParen); } --- 28,97 ---- private bool distinct = false; ! /// <summary> ! /// Certain databases don't like spaces around these operators. ! /// </summary> ! /// <remarks> ! /// This needs to contain both a plain string and a ! /// SqlString version of the operator because the portions in ! /// the WHERE clause will come in as SqlStrings since there ! /// might be parameters, other portions of the clause come in ! /// as strings since there are no parameters. ! /// </remarks> ! private static readonly ISet dontSpace = new HashedSet(); static QuerySelect() { //dontSpace.add("'"); ! dontSpace.Add( "." ); ! dontSpace.Add( "+" ); ! dontSpace.Add( "-" ); ! dontSpace.Add( "/" ); ! dontSpace.Add( "*" ); ! dontSpace.Add( "<" ); ! dontSpace.Add( ">" ); ! dontSpace.Add( "=" ); ! dontSpace.Add( "#" ); ! dontSpace.Add( "~" ); ! dontSpace.Add( "|" ); ! dontSpace.Add( "&" ); ! dontSpace.Add( "<=" ); ! dontSpace.Add( ">=" ); ! dontSpace.Add( "=>" ); ! dontSpace.Add( "=<" ); ! dontSpace.Add( "!=" ); ! dontSpace.Add( "<>" ); ! dontSpace.Add( "!#" ); ! dontSpace.Add( "!~" ); ! dontSpace.Add( "!<" ); ! dontSpace.Add( "!>" ); ! // MySQL doesn't like spaces around "(" or ")" also. ! dontSpace.Add( StringHelper.OpenParen ); ! dontSpace.Add( StringHelper.ClosedParen ); ! ! dontSpace.Add( new SqlString( "." ) ); ! dontSpace.Add( new SqlString( "+" ) ); ! dontSpace.Add( new SqlString( "-" ) ); ! dontSpace.Add( new SqlString( "/" ) ); ! dontSpace.Add( new SqlString( "*" ) ); ! dontSpace.Add( new SqlString( "<" ) ); ! dontSpace.Add( new SqlString( ">" ) ); ! dontSpace.Add( new SqlString( "=" ) ); ! dontSpace.Add( new SqlString( "#" ) ); ! dontSpace.Add( new SqlString( "~" ) ); ! dontSpace.Add( new SqlString( "|" ) ); ! dontSpace.Add( new SqlString( "&" ) ); ! dontSpace.Add( new SqlString( "<=" ) ); ! dontSpace.Add( new SqlString( ">=" ) ); ! dontSpace.Add( new SqlString( "=>" ) ); ! dontSpace.Add( new SqlString( "=<" ) ); ! dontSpace.Add( new SqlString( "!=" ) ); ! dontSpace.Add( new SqlString( "<>" ) ); ! dontSpace.Add( new SqlString( "!#" ) ); ! dontSpace.Add( new SqlString( "!~" ) ); ! dontSpace.Add( new SqlString( "!<" ) ); ! dontSpace.Add( new SqlString( "!>" ) ); ! // MySQL doesn't like spaces around "(" or ")" also. ! dontSpace.Add( new SqlString( StringHelper.OpenParen ) ); ! dontSpace.Add( new SqlString( StringHelper.ClosedParen ) ); } *************** *** 157,161 **** SqlString part1 = joins.ToWhereFragmentString.Trim(); ! SqlString part2 = whereBuilder.ToSqlString().Trim(); bool hasPart1 = part1.SqlParts.Length > 0; bool hasPart2 = part2.SqlParts.Length > 0; --- 196,200 ---- SqlString part1 = joins.ToWhereFragmentString.Trim(); ! SqlString part2 = whereBuilder.ToSqlString().Trim(); bool hasPart1 = part1.SqlParts.Length > 0; bool hasPart2 = part2.SqlParts.Length > 0; *************** *** 244,248 **** debugIndex++; ! if( tokenString!=null) { lastQuoted = tokenString.EndsWith("'"); --- 283,287 ---- debugIndex++; ! if( tokenString!=null ) { lastQuoted = tokenString.EndsWith("'"); *************** *** 250,254 **** else { ! tokenSqlString.EndsWith("'"); } } --- 289,293 ---- else { ! lastQuoted = tokenSqlString.EndsWith("'"); } } Index: Template.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Template.cs,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Template.cs 22 Nov 2004 03:56:08 -0000 1.9 --- Template.cs 4 Dec 2004 22:41:30 -0000 1.10 *************** *** 1,7 **** using System; using System.Collections; - using System.Collections.Specialized; using System.Text; using NHibernate.Dialect; using NHibernate.Util; --- 1,8 ---- using System; using System.Collections; using System.Text; + using Iesi.Collections; + using NHibernate.Dialect; using NHibernate.Util; *************** *** 17,21 **** public const string PlaceHolder = "$PlaceHolder"; ! private static StringDictionary Keywords = new StringDictionary(); private static ArrayList delimiterList = new ArrayList(13); private static string delimiters = null; --- 18,22 ---- public const string PlaceHolder = "$PlaceHolder"; ! private static ISet Keywords = new HashedSet(); private static ArrayList delimiterList = new ArrayList(13); private static string delimiters = null; *************** *** 23,41 **** static Template() { ! Keywords["and"] = String.Empty; ! Keywords["or"] = String.Empty; ! Keywords["not"] = String.Empty; ! Keywords["like"] = String.Empty; ! Keywords["is"] = String.Empty; ! Keywords["in"] = String.Empty; ! Keywords["between"] = String.Empty; ! Keywords["null"] = String.Empty; ! Keywords["select"] = String.Empty; ! Keywords["from"] = String.Empty; ! Keywords["where"] = String.Empty; ! Keywords["having"] = String.Empty; ! Keywords["group"] = String.Empty; ! Keywords["order"] = String.Empty; ! Keywords["by"] = String.Empty; delimiterList.Add(" "); --- 24,42 ---- static Template() { ! Keywords.Add( "and" ); ! Keywords.Add( "or" ); ! Keywords.Add( "not" ); ! Keywords.Add( "like" ); ! Keywords.Add( "is" ); ! Keywords.Add( "in" ); ! Keywords.Add( "between" ); ! Keywords.Add( "null" ); ! Keywords.Add( "select" ); ! Keywords.Add( "from" ); ! Keywords.Add( "where" ); ! Keywords.Add( "having" ); ! Keywords.Add( "group" ); ! Keywords.Add( "order" ); ! Keywords.Add( "by" ); delimiterList.Add(" "); *************** *** 70,74 **** public static void AddKeyword(string keyword) { ! Keywords[keyword] = String.Empty; } --- 71,75 ---- public static void AddKeyword(string keyword) { ! Keywords.Add( keyword ); } *************** *** 125,129 **** bool isIdentifier = token[0]=='`' || ( // allow any identifier quoted with backtick Char.IsLetter(token[0]) && // only recognizes identifiers beginning with a letter ! !Keywords.ContainsKey( token.ToLower() ) && token.IndexOf('.') < 0 ); --- 126,130 ---- bool isIdentifier = token[0]=='`' || ( // allow any identifier quoted with backtick Char.IsLetter(token[0]) && // only recognizes identifiers beginning with a letter ! !Keywords.Contains( token.ToLower() ) && token.IndexOf('.') < 0 ); Index: Parameter.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/SqlCommand/Parameter.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Parameter.cs 21 Sep 2004 09:58:25 -0000 1.10 --- Parameter.cs 4 Dec 2004 22:41:29 -0000 1.11 *************** *** 133,141 **** public override int GetHashCode() { ! int hashCode; unchecked { ! hashCode = _sqlType.GetHashCode() + name.GetHashCode(); if(tableAlias!=null) { --- 133,148 ---- public override int GetHashCode() { ! int hashCode = 0; unchecked { ! if( _sqlType!=null ) ! { ! hashCode += _sqlType.GetHashCode(); ! } ! if( name!=null ) ! { ! hashCode += name.GetHashCode(); ! } if(tableAlias!=null) { |