From: Peter S. <sz...@us...> - 2004-04-30 14:06:55
|
Update of /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18403/NHibernate/Hql Modified Files: QueryTranslator.cs Log Message: HQL looks like finished. Changed string.Empty to String.Empty. Index: QueryTranslator.cs =================================================================== RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate/Hql/QueryTranslator.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** QueryTranslator.cs 29 Apr 2004 14:00:52 -0000 1.26 --- QueryTranslator.cs 30 Apr 2004 14:06:46 -0000 1.27 *************** *** 119,122 **** --- 119,123 ---- this.replacements = replacements; this.shallowQuery = scalar; + Compile(queryString); } *************** *** 268,284 **** } - private string Prefix(string s) - { - //TODO: H2.0.3: Using Prefix or using alias? - if ( s.Length > 3 ) - { - return s.Substring(0, 3).ToLower(); - } - else - { - return s.ToLower(); - } - } - private int NextCount() { --- 269,272 ---- *************** *** 298,302 **** { return CreateName(type.Name); - //return Prefix(type.Name) + NextCount() + StringHelper.Underscore; } --- 286,289 ---- *************** *** 304,308 **** { return CreateName(role); - //return Prefix( StringHelper.Unqualify(role) ) + NextCount() + StringHelper.Underscore; } --- 291,294 ---- *************** *** 556,559 **** --- 542,546 ---- { string name = (string) returnTypes[i]; + //if ( !IsName(name) ) throw new QueryException("unknown type: " + name); persisters[i] = GetPersisterForName(name); suffixes[i] = (size==1) ? String.Empty : i.ToString() + StringHelper.Underscore; *************** *** 564,568 **** } ! string scalarSelect = RenderScalarSelect(); int scalarSize = scalarTypes.Count; --- 551,555 ---- } ! string scalarSelect = RenderScalarSelect(); //Must be done here because of side-effect! yuck... int scalarSize = scalarTypes.Count; *************** *** 586,591 **** if ( CollectionPersister!=null ) { ! //TODO: H2.0.3: When collection is updated ! //sql.AddSelectFragmentString( CollectionPersister.MultiselectClauseFragment(fetchName) ); } if ( hasScalars || shallowQuery ) sql.AddSelectFragmentString(scalarSelect); --- 573,577 ---- if ( CollectionPersister!=null ) { ! sql.AddSelectFragmentString( collectionPersister.MultiselectClauseFragment(fetchName) ); } if ( hasScalars || shallowQuery ) sql.AddSelectFragmentString(scalarSelect); *************** *** 602,607 **** if ( CollectionPersister!=null && CollectionPersister.HasOrdering ) { ! //TODO: H2.0.3: When Sql/QuerySelect is updated ! //sql.addOrderBy( CollectionPersister.GetSQLOrderByString(fetchName) ); } --- 588,592 ---- if ( CollectionPersister!=null && CollectionPersister.HasOrdering ) { ! sql.AddOrderBy( CollectionPersister.GetSQLOrderByString(fetchName) ); } *************** *** 652,655 **** --- 637,657 ---- } + private string RenderOrderByPropertiesSelect() + { + StringBuilder buf = new StringBuilder(10); + + //add the columns we are ordering by to the select ID select clause + foreach(string token in orderByTokens) + { + if ( token.LastIndexOf(".") > 0 ) + { + //ie. it is of form "foo.bar", not of form "asc" or "desc" + buf.Append(StringHelper.CommaSpace).Append(token); + } + } + + return buf.ToString(); + } + private void RenderPropertiesSelect(QuerySelect sql) { *************** *** 687,691 **** if (i != names.Length - 1 || k != size - 1) buf.Append(StringHelper.CommaSpace); } - } } --- 689,692 ---- *************** *** 740,743 **** --- 741,745 ---- private JoinFragment MergeJoins(JoinFragment ojf) { + //classes foreach(string name in typeMap.Keys) { *************** *** 777,780 **** --- 779,783 ---- /// Is this query called by Scroll() or Iterate()? /// </summary> + /// <value>true if it is, false if it is called by find() or list()</value> public bool IsShallowQuery { *************** *** 793,800 **** internal bool Distinct { - // get - // { - // return distinct; - // } set { --- 796,799 ---- *************** *** 832,843 **** return suffixes; } - set - { - suffixes = value; - } } protected void AddFromCollection(string elementName, string collectionRole) { IType collectionElementType = GetCollectionPersister(collectionRole).ElementType; if ( !collectionElementType.IsEntityType ) throw new QueryException( --- 831,839 ---- return suffixes; } } protected void AddFromCollection(string elementName, string collectionRole) { + //q.addCollection(collectionName, collectionRole); IType collectionElementType = GetCollectionPersister(collectionRole).ElementType; if ( !collectionElementType.IsEntityType ) throw new QueryException( *************** *** 896,899 **** --- 892,896 ---- if (namedParams != null) { + // assumes that types are all of span 1 int result = 0; foreach (DictionaryEntry e in namedParams) *************** *** 939,944 **** } - - public static string[] ConcreteQueries(string query, ISessionFactoryImplementor factory) { --- 936,939 ---- *************** *** 961,965 **** for (int i=1; i<tokens.Length; i++) { - //update last non-whitespace token, if necessary if ( !ParserHelper.IsWhitespace( tokens[i-1] ) ) last = tokens[i-1].ToLower(); --- 956,959 ---- *************** *** 968,972 **** if ( ParserHelper.IsWhitespace(token) || last==null ) { - // scan for the next non-whitespace token if (nextIndex<=i) --- 962,965 ---- *************** *** 979,982 **** --- 972,976 ---- } + //if ( Character.isUpperCase( token.charAt( token.lastIndexOf(".") + 1 ) ) ) { if ( ( beforeClassTokens.Contains(last) && !notAfterClassTokens.Contains(next) ) || *************** *** 1014,1020 **** { beforeClassTokens.Add("from"); beforeClassTokens.Add(","); notAfterClassTokens.Add("in"); ! notAfterClassTokens.Add(","); notAfterClassTokens.Add("from"); notAfterClassTokens.Add(")"); --- 1008,1015 ---- { beforeClassTokens.Add("from"); + //beforeClassTokens.Add("new"); DEFINITELY DON'T HAVE THIS!! beforeClassTokens.Add(","); notAfterClassTokens.Add("in"); ! //notAfterClassTokens.Add(","); notAfterClassTokens.Add("from"); notAfterClassTokens.Add(")"); *************** *** 1070,1073 **** --- 1065,1069 ---- { IType[] returnTypes = ReturnTypes; + row = ToResultRow(row); if (hasScalars) { *************** *** 1123,1134 **** internal QueryJoinFragment CreateJoinFragment(bool useThetaStyleInnerJoins) { ! return new QueryJoinFragment( factory.Dialect ); ! //TODO: H2.0.3 when QueryJoinFragment is updated ! //return new QueryJoinFragment( factory.Dialect, useThetaStyleInnerJoins ); } internal System.Type HolderClass { - get { return holderClass; } set { holderClass = value; } } --- 1119,1127 ---- internal QueryJoinFragment CreateJoinFragment(bool useThetaStyleInnerJoins) { ! return new QueryJoinFragment( factory.Dialect, useThetaStyleInnerJoins ); } internal System.Type HolderClass { set { holderClass = value; } } |