예제 #1
0
        public void Compile()
        {
            try
            {
                _select  = new HqlSelect(_settings);
                _from    = new HqlFrom();
                _where   = new HqlWhere(HqlWhere.NAME_WHERE);
                _groupby = new HqlGroupBy();
                _having  = new HqlHaving(_select);
                _orderby = new HqlOrderBy();

                HqlTokenProcessor processor = new HqlTokenProcessor(_sql, _settings, _references);

                Compile_Inner(processor);

                PostCompile(processor);
            }
            catch
            {
                throw;
            }
        }
예제 #2
0
        static private void CheckFieldIntoGroupBy(HqlGroupBy groupby, HqlField f, string type, HqlField entireField)
        {
            if (f.HasFunction)
            {
                return;
            }
            if (f.IsLiteralType)
            {
                return;
            }
            if (!f.PrintResult)
            {
                return;
            }

            if (groupby.ContainsField(f))
            {
                return;
            }

            if (!f.HasScalar)
            {
                throw new Exception(String.Format("Expected the {0} value of {1} in the GROUP-BY", type, f.GetFullName()));
            }
            else if (f.HasScalar)
            {
                if (f.Scalar.HasMultipleFields)
                {
                    HqlField[] fields = f.Scalar.Fields;
                    if (fields == null)
                    {
                        throw new Exception(String.Format("Expected the {0} value of {1} in the GROUP-BY", type, f.GetFullName()));
                    }

                    for (int j = 0; j < fields.Length; j++)
                    {
                        HqlField ff = fields[j];

                        CheckFieldIntoGroupBy(groupby, ff, type, entireField);
                    }
                }
                else
                {
                    f = f.FinalField;

                    if (f.IsLiteralType)
                    {
                        return;
                    }

                    if (!groupby.ContainsField(f))
                    {
                        throw new Exception(String.Format("Expected the {0} value of {1} in the GROUP-BY", type, f.GetFullName()));
                    }
                }
            }
            else
            {
                throw new Exception("Unknown case of FIELD");
            }
        }