private void InitializeMembers() { this.columnExpression = null; this.columnIdentifier = null; this.tableReference = null; this.columnName = null; this.dataType = DataType.Unknown; this.columnAlias = null; this.isStar = false; this.isComplexExpression = false; this.selectListIndex = -1; this.columnContext = Graywulf.SqlParser.ColumnContext.None; }
private void CopyMembers(ColumnReference old) { this.columnExpression = old.columnExpression; this.columnIdentifier = old.columnIdentifier; this.tableReference = old.tableReference; this.columnName = old.columnName; this.dataType = old.dataType; this.columnAlias = old.columnAlias; this.isStar = old.isStar; this.isComplexExpression = old.isComplexExpression; this.selectListIndex = old.selectListIndex; this.columnContext = old.columnContext; }
private void InterpretColumnIdentifier(ColumnIdentifier ci) { var ds = ci.FindDescendant <DatasetName>(); DatasetName = (ds != null) ? Util.RemoveIdentifierQuotes(ds.Value) : null; var dbn = ci.FindDescendant <DatabaseName>(); DatabaseName = (dbn != null) ? Util.RemoveIdentifierQuotes(dbn.Value) : null; var sn = ci.FindDescendant <SchemaName>(); SchemaName = (sn != null) ? Util.RemoveIdentifierQuotes(sn.Value) : null; var tn = ci.FindDescendant <TableName>(); DatabaseObjectName = (tn != null) ? Util.RemoveIdentifierQuotes(tn.Value) : null; }
public static ColumnIdentifier Create(ColumnReference cr) { var nci = new ColumnIdentifier(); nci.ColumnReference = cr; if (String.IsNullOrEmpty(cr.TableReference.Alias)) { nci.Stack.AddLast(TableName.Create(cr.TableReference.DatabaseObjectName)); } else { nci.Stack.AddLast(TableName.Create(cr.TableReference.Alias)); } nci.Stack.AddLast(Dot.Create()); nci.Stack.AddLast(ColumnName.Create(cr.ColumnName)); return nci; }
public static ColumnIdentifier Create(ColumnReference cr) { var nci = new ColumnIdentifier(); nci.ColumnReference = cr; if (String.IsNullOrEmpty(cr.TableReference.Alias)) { nci.Stack.AddLast(TableName.Create(cr.TableReference.DatabaseObjectName)); } else { nci.Stack.AddLast(TableName.Create(cr.TableReference.Alias)); } nci.Stack.AddLast(Dot.Create()); nci.Stack.AddLast(ColumnName.Create(cr.ColumnName)); return(nci); }
public static SelectList Create(ColumnReference cr) { // Create new expression var nsl = new SelectList(); var nce = new ColumnExpression(); nce.ColumnReference = new ColumnReference(cr); nsl.Stack.AddLast(nce); var nex = new Expression(); nce.Stack.AddLast(nex); var nav = new AnyVariable(); nex.Stack.AddLast(nav); nav.Stack.AddLast(ColumnIdentifier.Create(new ColumnReference(cr))); return(nsl); }
protected void ValidateColumnIdentifier(QuerySpecification qs, ColumnIdentifier ci) { // TODO: modify to look for stars inside expressions /* * if (ci.ColumnReference.IsStar) * { * // Check if it's a count(*), that's the only expression allowed to * // contain a * * var fc = ci.FindAscendant<FunctionCall>(); * if (fc != null) * { * var fn = fc.FindDescendantRecursive<FunctionName>(); * if (fn != null && SqlParser.ComparerInstance.Compare(fn.Value, "COUNT") == 0) * { * return; * } * } * * throw CreateException(ExceptionMessages.StarColumnNotAllowed, null, null, ci); * }*/ }
public static ColumnReference Interpret(ColumnIdentifier ci) { var cr = new ColumnReference(); cr.columnIdentifier = ci; cr.tableReference = new TableReference(ci); var star = ci.FindDescendant <Mul>(); if (star != null) { cr.isStar = true; cr.columnName = star.Value; } else { cr.isStar = false; cr.columnName = Util.RemoveIdentifierQuotes(ci.FindDescendant <ColumnName>().Value); } cr.isComplexExpression = false; return(cr); }
protected void ValidateColumnIdentifier(QuerySpecification qs, ColumnIdentifier ci) { // TODO: modify to look for stars inside expressions /* if (ci.ColumnReference.IsStar) { // Check if it's a count(*), that's the only expression allowed to // contain a * var fc = ci.FindAscendant<FunctionCall>(); if (fc != null) { var fn = fc.FindDescendantRecursive<FunctionName>(); if (fn != null && SqlParser.ComparerInstance.Compare(fn.Value, "COUNT") == 0) { return; } } throw CreateException(ExceptionMessages.StarColumnNotAllowed, null, null, ci); }*/ }
public TableReference(ColumnIdentifier ci) : this() { InitializeMembers(); InterpretColumnIdentifier(ci); }
private void InterpretColumnIdentifier(ColumnIdentifier ci) { var ds = ci.FindDescendant<DatasetName>(); datasetName = (ds != null) ? Util.RemoveIdentifierQuotes(ds.Value) : null; var dbn = ci.FindDescendant<DatabaseName>(); databaseName = (dbn != null) ? Util.RemoveIdentifierQuotes(dbn.Value) : null; var sn = ci.FindDescendant<SchemaName>(); schemaName = (sn != null) ? Util.RemoveIdentifierQuotes(sn.Value) : null; var tn = ci.FindDescendant<TableName>(); databaseObjectName = (tn != null) ? Util.RemoveIdentifierQuotes(tn.Value) : null; }
public static ColumnReference Interpret(ColumnIdentifier ci) { var cr = new ColumnReference(); cr.columnIdentifier = ci; cr.tableReference = new TableReference(ci); var star = ci.FindDescendant<Mul>(); if (star != null) { cr.isStar = true; cr.columnName = star.Value; } else { cr.isStar = false; cr.columnName = Util.RemoveIdentifierQuotes(ci.FindDescendant<ColumnName>().Value); } cr.isComplexExpression = false; return cr; }
/// <summary> /// Writes a column identifier, optionally with resolved /// names and quoted /// </summary> /// <param name="node"></param> /// <returns></returns> public void WriteColumnIdentifier(ColumnIdentifier node) { if (ResolveNames) { Writer.Write(GetResolvedColumnName(node.ColumnReference)); } else { // Fall back to original behavior base.WriteNode(node); } }
public abstract bool WriteColumnIdentifier(ColumnIdentifier node);