Пример #1
0
 protected override void ColumnRef(IColumnReference colref)
 {
     if (colref.SpecificData.ContainsKey("mysql.sub_part"))
     {
         Put("%i(%s)", colref.ColumnName, colref.SpecificData["mysql.sub_part"]);
     }
     else
     {
         base.ColumnRef(colref);
     }
 }
Пример #2
0
        private void ResolveColumnReference(QuerySpecification qs, IColumnReference cr, ColumnContext context)
        {
            // Try to resolve the table belonging to a column based solely on
            // column name. This function is called only on column references with
            // unspecified table parts.
            // Star columns cannot be resolved, treat them separately

            if (!cr.ColumnReference.IsStar && !cr.ColumnReference.IsComplexExpression)
            {

                ColumnReference ncr = null;
                int q = 0;

                if (cr.ColumnReference.TableReference.IsUndefined)
                {
                    // This has an empty table reference (only column name specified)
                    // Look for a match based on column name only
                    foreach (var tr in qs.SourceTableReferences.Values)
                    {
                        foreach (var ccr in tr.ColumnReferences)
                        {
                            if (cr.ColumnReference.Compare(ccr))
                            {
                                if (q != 0)
                                {
                                    throw CreateException(ExceptionMessages.AmbigousColumnReference, null, cr.ColumnReference.ColumnName, (Node)cr);
                                }

                                ncr = ccr;
                                q++;
                            }
                        }
                    }
                }
                else if (!cr.ColumnReference.TableReference.IsUndefined)
                {
                    foreach (var ccr in cr.ColumnReference.TableReference.ColumnReferences)
                    {
                        if (cr.ColumnReference.Compare(ccr))
                        {
                            if (q != 0)
                            {
                                throw CreateException(ExceptionMessages.AmbigousColumnReference, null, cr.ColumnReference.ColumnName, (Node)cr);
                            }

                            ncr = ccr;
                            q++;
                        }
                    }
                }

                if (q == 0)
                {
                    throw CreateException(ExceptionMessages.UnresolvableColumnReference, null, cr.ColumnReference.ColumnName, (Node)cr);
                }

                // Make copy here and preserve alias!
                ncr.ColumnContext |= context;

                ncr = new ColumnReference(ncr);
                if (cr.ColumnReference != null && cr.ColumnReference.ColumnAlias != null)
                {
                    ncr.ColumnAlias = cr.ColumnReference.ColumnAlias;
                }
                cr.ColumnReference = ncr;
            }
        }
Пример #3
0
 public ColumnReference(IColumnReference src)
 {
     ColumnName   = src.ColumnName;
     SpecificData = new Dictionary <string, string>();
     SpecificData.AddAll(src.SpecificData);
 }
Пример #4
0
        private void ResolveColumnReference(QuerySpecification qs, IColumnReference cr, ColumnContext context)
        {
            // Try to resolve the table belonging to a column based solely on
            // column name. This function is called only on column references with
            // unspecified table parts.
            // Star columns cannot be resolved, treat them separately

            if (!cr.ColumnReference.IsStar && !cr.ColumnReference.IsComplexExpression)
            {
                ColumnReference ncr = null;
                int             q   = 0;

                if (cr.ColumnReference.TableReference.IsUndefined)
                {
                    // This has an empty table reference (only column name specified)
                    // Look for a match based on column name only
                    foreach (var tr in qs.SourceTableReferences.Values)
                    {
                        foreach (var ccr in tr.ColumnReferences)
                        {
                            if (cr.ColumnReference.Compare(ccr))
                            {
                                if (q != 0)
                                {
                                    throw CreateException(ExceptionMessages.AmbigousColumnReference, null, cr.ColumnReference.ColumnName, (Node)cr);
                                }

                                ncr = ccr;
                                q++;
                            }
                        }
                    }
                }
                else if (!cr.ColumnReference.TableReference.IsUndefined)
                {
                    foreach (var ccr in cr.ColumnReference.TableReference.ColumnReferences)
                    {
                        if (cr.ColumnReference.Compare(ccr))
                        {
                            if (q != 0)
                            {
                                throw CreateException(ExceptionMessages.AmbigousColumnReference, null, cr.ColumnReference.ColumnName, (Node)cr);
                            }

                            ncr = ccr;
                            q++;
                        }
                    }
                }

                if (q == 0)
                {
                    throw CreateException(ExceptionMessages.UnresolvableColumnReference, null, cr.ColumnReference.ColumnName, (Node)cr);
                }

                // Make copy here and preserve alias!
                ncr.ColumnContext |= context;

                ncr = new ColumnReference(ncr);
                if (cr.ColumnReference != null && cr.ColumnReference.ColumnAlias != null)
                {
                    ncr.ColumnAlias = cr.ColumnReference.ColumnAlias;
                }
                cr.ColumnReference = ncr;
            }
        }
Пример #5
0
 protected virtual void ColumnRef(IColumnReference colref)
 {
     WriteRaw(QuoteIdentifier(colref.ColumnName, null));
 }
Пример #6
0
 public ColumnRefTreeNode(ITreeNode parent, IColumnReference column)
     : base(parent, column.ColumnName)
 {
     m_column = column;
 }