From: Michael D. <mik...@us...> - 2004-12-04 22:42:06
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1955/NHibernate/Hql Modified Files: HavingParser.cs PreprocessingParser.cs QueryTranslator.cs SelectParser.cs WhereParser.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: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** QueryTranslator.cs 22 Nov 2004 03:53:07 -0000 1.49 --- QueryTranslator.cs 4 Dec 2004 22:41:20 -0000 1.50 *************** *** 1,11 **** using System; using System.Collections; - using System.Collections.Specialized; using System.Data; - using System.Text; - using System.Text.RegularExpressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using NHibernate; --- 1,12 ---- using System; using System.Collections; using System.Data; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; + using System.Text; + using System.Text.RegularExpressions; + + using Iesi.Collections; using NHibernate; *************** *** 27,32 **** { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(QueryTranslator)); ! private static StringCollection dontSpace = new StringCollection(); ! private IDictionary typeMap = new SequencedHashMap(); private IDictionary collections = new SequencedHashMap(); --- 28,32 ---- { private static readonly log4net.ILog log = log4net.LogManager.GetLogger(typeof(QueryTranslator)); ! private IDictionary typeMap = new SequencedHashMap(); private IDictionary collections = new SequencedHashMap(); *************** *** 36,40 **** private IDictionary namedParameters = new Hashtable(); private IDictionary aliasNames = new Hashtable(); ! private ArrayList crossJoins = new ArrayList(); // contains a List of strings --- 36,40 ---- private IDictionary namedParameters = new Hashtable(); private IDictionary aliasNames = new Hashtable(); ! private ISet crossJoins = new HashedSet(); // contains a List of strings *************** *** 47,52 **** private IList orderByTokens = new ArrayList(); private IList groupByTokens = new ArrayList(); ! private ArrayList identifierSpaces = new ArrayList(); ! private ArrayList entitiesToFetch = new ArrayList(); private IQueryable[] persisters; --- 47,53 ---- private IList orderByTokens = new ArrayList(); private IList groupByTokens = new ArrayList(); ! ! private ISet identifierSpaces = new HashedSet(); ! private ISet entitiesToFetch = new HashedSet(); private IQueryable[] persisters; *************** *** 147,155 **** { qe.QueryString = queryString; ! throw qe; } catch (MappingException me) { ! throw me; } catch (Exception e) --- 148,156 ---- { qe.QueryString = queryString; ! throw; } catch (MappingException me) { ! throw; } catch (Exception e) *************** *** 785,794 **** } ! public IList QuerySpaces { ! get ! { ! return identifierSpaces; ! } } --- 786,792 ---- } ! public ISet QuerySpaces { ! get { return identifierSpaces; } } *************** *** 982,987 **** //if ( Character.isUpperCase( token.charAt( token.lastIndexOf(".") + 1 ) ) ) { if ( ! ( beforeClassTokens.Contains(last) && !notAfterClassTokens.Contains(next) ) || "class".Equals(last) ) { --- 980,987 ---- //if ( Character.isUpperCase( token.charAt( token.lastIndexOf(".") + 1 ) ) ) { + // added the checks for last!=null and next==null because an ISet can not contain + // a null key in .net - it is valid for a null key to be in a java.util.Set if ( ! ( ( last!=null && beforeClassTokens.Contains(last) ) && ( next==null || !notAfterClassTokens.Contains(next) ) ) || "class".Equals(last) ) { *************** *** 1011,1026 **** ! private static readonly IList beforeClassTokens = new ArrayList(); ! private static readonly IList notAfterClassTokens = new ArrayList(); static QueryTranslator() { ! beforeClassTokens.Add("from"); //beforeClassTokens.Add("new"); DEFINITELY DON'T HAVE THIS!! ! beforeClassTokens.Add(","); ! notAfterClassTokens.Add("in"); //notAfterClassTokens.Add(","); ! notAfterClassTokens.Add("from"); ! notAfterClassTokens.Add(")"); } --- 1011,1027 ---- ! private static readonly ISet beforeClassTokens = new HashedSet(); ! private static readonly ISet notAfterClassTokens = new HashedSet(); static QueryTranslator() { ! beforeClassTokens.Add( "from" ); //beforeClassTokens.Add("new"); DEFINITELY DON'T HAVE THIS!! ! beforeClassTokens.Add( "," ); ! ! notAfterClassTokens.Add( "in" ); //notAfterClassTokens.Add(","); ! notAfterClassTokens.Add( "from" ); ! notAfterClassTokens.Add( ")" ); } Index: WhereParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/WhereParser.cs,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** WhereParser.cs 22 Nov 2004 03:53:07 -0000 1.25 --- WhereParser.cs 4 Dec 2004 22:41:20 -0000 1.26 *************** *** 1,7 **** using System; using System.Collections; - using System.Collections.Specialized; using System.Text; using NHibernate.Persister; using NHibernate.Type; --- 1,8 ---- using System; using System.Collections; using System.Text; + using Iesi.Collections; + using NHibernate.Persister; using NHibernate.Type; *************** *** 29,35 **** ! private static StringCollection expressionTerminators = new StringCollection(); //tokens that close a sub expression ! private static StringCollection expressionOpeners = new StringCollection(); //tokens that open a sub expression ! private static StringCollection booleanOperators = new StringCollection(); //tokens that would indicate a sub expression is a boolean expression private static IDictionary negations = new Hashtable(); --- 30,36 ---- ! private static ISet expressionTerminators = new HashedSet(); //tokens that close a sub expression ! private static ISet expressionOpeners = new HashedSet(); //tokens that open a sub expression ! private static ISet booleanOperators = new HashedSet(); //tokens that would indicate a sub expression is a boolean expression private static IDictionary negations = new Hashtable(); *************** *** 555,559 **** else { ! q.AppendWhereToken( new SqlCommand.SqlString(token) ); } } --- 556,566 ---- else { ! // a String.Empty can get passed in here. If that occurs ! // then don't create a new SqlString for it - just ignore ! // it since it adds nothing to the sql being generated. ! if( token!=null && token.Length>0) ! { ! q.AppendWhereToken( new SqlCommand.SqlString(token) ); ! } } } Index: PreprocessingParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/PreprocessingParser.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PreprocessingParser.cs 14 Apr 2004 11:35:53 -0000 1.4 --- PreprocessingParser.cs 4 Dec 2004 22:41:20 -0000 1.5 *************** *** 1,6 **** using System; using System.Collections; - using System.Collections.Specialized; using System.Text; using NHibernate.Util; --- 1,8 ---- using System; using System.Collections; using System.Text; + + using Iesi.Collections; + using NHibernate.Util; *************** *** 11,35 **** public class PreprocessingParser : IParser { ! private static StringCollection operators; private static IDictionary collectionProps; static PreprocessingParser() { ! operators = new StringCollection(); ! operators.Add("<="); ! operators.Add(">="); ! operators.Add("=>"); ! operators.Add("=<"); ! operators.Add("!="); ! operators.Add("<>"); ! operators.Add("!#"); ! operators.Add("!~"); ! operators.Add("!<"); ! operators.Add("!>"); ! operators.Add("is not"); ! operators.Add("not like"); ! operators.Add("not in"); ! operators.Add("not between"); ! operators.Add("not exists"); collectionProps = new Hashtable(); --- 13,37 ---- public class PreprocessingParser : IParser { ! private static ISet operators; private static IDictionary collectionProps; static PreprocessingParser() { ! operators = new HashedSet(); ! operators.Add( "<=" ); ! operators.Add( ">=" ); ! operators.Add( "=>" ); ! operators.Add( "=<" ); ! operators.Add( "!=" ); ! operators.Add( "<>" ); ! operators.Add( "!#" ); ! operators.Add( "!~" ); ! operators.Add( "!<" ); ! operators.Add( "!>" ); ! operators.Add( "is not" ); ! operators.Add( "not like" ); ! operators.Add( "not in" ); ! operators.Add( "not between" ); ! operators.Add( "not exists" ); collectionProps = new Hashtable(); Index: SelectParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/SelectParser.cs,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SelectParser.cs 30 Apr 2004 09:22:28 -0000 1.8 --- SelectParser.cs 4 Dec 2004 22:41:20 -0000 1.9 *************** *** 1,6 **** using System; - using System.Data; using System.Collections; ! using System.Collections.Specialized; using NHibernate; using NHibernate.Util; --- 1,8 ---- using System; using System.Collections; ! using System.Data; ! ! using Iesi.Collections; ! using NHibernate; using NHibernate.Util; *************** *** 18,28 **** private ArrayList aggregateFuncTokenList = new ArrayList(); private static IDictionary aggregateFunctions = new Hashtable(); ! private static StringCollection countArguments = new StringCollection(); static SelectParser() { ! countArguments.Add("distinct"); ! countArguments.Add("all"); ! countArguments.Add("*"); } --- 20,30 ---- private ArrayList aggregateFuncTokenList = new ArrayList(); private static IDictionary aggregateFunctions = new Hashtable(); ! private static ISet countArguments = new HashedSet(); static SelectParser() { ! countArguments.Add( "distinct" ); ! countArguments.Add( "all" ); ! countArguments.Add( "*" ); } Index: HavingParser.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/HavingParser.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** HavingParser.cs 30 Apr 2004 08:57:59 -0000 1.6 --- HavingParser.cs 4 Dec 2004 22:41:19 -0000 1.7 *************** *** 13,19 **** { } protected override void AppendToken(QueryTranslator q, string token) { ! q.AppendHavingToken(token); } } --- 13,26 ---- { } + protected override void AppendToken(QueryTranslator q, string token) { ! // a String.Empty can get passed in here. If that occurs ! // then don't create a new SqlString for it - just ignore ! // it since it adds nothing to the sql being generated. ! if( token!=null && token.Length>0 ) ! { ! q.AppendHavingToken(token); ! } } } |