public override SqlObject VisitIdentifierPathExpression([NotNull] sqlParser.IdentifierPathExpressionContext context) { Contract.Requires(context != null); SqlPathExpression pathExpression = (SqlPathExpression)this.Visit(context.path_expression()); SqlIdentifier identifier = SqlIdentifier.Create(context.IDENTIFIER().GetText()); return(SqlIdentifierPathExpression.Create(parentPath: pathExpression, value: identifier)); }
public override void Visit(SqlIdentifierPathExpression sqlIdentifierPathExpression) { if (sqlIdentifierPathExpression.ParentPath != null) { sqlIdentifierPathExpression.ParentPath.Accept(this); } this.writer.Write("."); sqlIdentifierPathExpression.Value.Accept(this); }
public override int Visit(SqlIdentifierPathExpression sqlIdentifierPathExpression) { int hashCode = SqlIdentifierPathExpressionHashCode; if (sqlIdentifierPathExpression.ParentPath != null) { hashCode = CombineHashes(hashCode, sqlIdentifierPathExpression.ParentPath.Accept(this)); } hashCode = CombineHashes(hashCode, sqlIdentifierPathExpression.Value.Accept(this)); return(hashCode); }
public override bool Visit(SqlIdentifierPathExpression first, SqlObject secondAsObject) { if (!(secondAsObject is SqlIdentifierPathExpression second)) { return(false); } if (!first.Value.Accept(this, second.Value)) { return(false); } if (!first.ParentPath.Accept(this, second.ParentPath)) { return(false); } return(true); }
public abstract void Visit(SqlIdentifierPathExpression sqlObject);
public override SqlObject Visit(SqlIdentifierPathExpression sqlIdentifierPathExpression) { return(SqlIdentifierPathExpression.Create( sqlIdentifierPathExpression.ParentPath?.Accept(this) as SqlPathExpression, sqlIdentifierPathExpression.Value.Accept(this) as SqlIdentifier)); }
public abstract TResult Visit(SqlIdentifierPathExpression sqlObject);
public void AliasedCollectionExpressionTest() { // FROM c SqlAliasedCollectionExpression fromC = SqlAliasedCollectionExpression.Create( SqlInputPathCollection.Create( SqlIdentifier.Create("c"), relativePath: null), alias: null); CosmosObject andersenWrapped = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["c"] = AndersenFamily, ["_rid"] = AndersenFamily["_rid"] }); CosmosObject wakeFieldWrapped = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["c"] = WakefieldFamily, ["_rid"] = WakefieldFamily["_rid"] }); AssertEvaluation(new CosmosElement[] { andersenWrapped, wakeFieldWrapped }, fromC, DataSource); // FROM c.id SqlAliasedCollectionExpression fromCDotId = SqlAliasedCollectionExpression.Create( SqlInputPathCollection.Create( SqlIdentifier.Create("c"), SqlIdentifierPathExpression.Create( null, SqlIdentifier.Create("id"))), alias: null); CosmosObject andersenId = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["id"] = CosmosString.Create("AndersenFamily"), ["_rid"] = AndersenFamily["_rid"] }); CosmosObject wakefieldId = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["id"] = CosmosString.Create("WakefieldFamily"), ["_rid"] = WakefieldFamily["_rid"] }); AssertEvaluation(new CosmosElement[] { andersenId, wakefieldId }, fromCDotId, DataSource); // FROM c.id AS familyId SqlAliasedCollectionExpression fromCDotIdAsFamilyId = SqlAliasedCollectionExpression.Create( SqlInputPathCollection.Create( SqlIdentifier.Create("c"), SqlIdentifierPathExpression.Create( null, SqlIdentifier.Create("id"))), SqlIdentifier.Create("familyId")); CosmosObject andersenIdAsFamilyId = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["familyId"] = CosmosString.Create("AndersenFamily"), ["_rid"] = AndersenFamily["_rid"] }); CosmosObject wakefieldIdAsFamilyId = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["familyId"] = CosmosString.Create("WakefieldFamily"), ["_rid"] = WakefieldFamily["_rid"] }); AssertEvaluation(new CosmosElement[] { andersenIdAsFamilyId, wakefieldIdAsFamilyId }, fromCDotIdAsFamilyId, DataSource); // FROM (SELECT VALUE child["grade"] FROM child IN c.children) grade SqlAliasedCollectionExpression fromSubqueryGrades = SqlAliasedCollectionExpression.Create( SqlSubqueryCollection.Create( SqlQuery.Create( SqlSelectClause.Create( SqlSelectValueSpec.Create( TestUtils.CreatePathExpression("child", "grade"))), SqlFromClause.Create( SqlArrayIteratorCollectionExpression.Create( SqlIdentifier.Create("child"), SqlInputPathCollection.Create( SqlIdentifier.Create("c"), SqlStringPathExpression.Create( null, SqlStringLiteral.Create("children"))))), whereClause: null, groupByClause: null, orderByClause: null, offsetLimitClause: null)), SqlIdentifier.Create("grade")); CosmosObject henrietteWrapped = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["grade"] = CosmosNumber64.Create(5), ["_rid"] = AndersenFamily["_rid"] }); CosmosObject jesseWrapped = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["grade"] = CosmosNumber64.Create(1), ["_rid"] = WakefieldFamily["_rid"] }); CosmosObject lisaWrapped = CosmosObject.Create(new Dictionary <string, CosmosElement> { ["grade"] = CosmosNumber64.Create(8), ["_rid"] = WakefieldFamily["_rid"] }); AssertEvaluation( new CosmosElement[] { henrietteWrapped, jesseWrapped, lisaWrapped }, fromSubqueryGrades, DataSource); }
public abstract TOutput Visit(SqlIdentifierPathExpression sqlObject, TArg input);
public override IEnumerable <Either <long, string> > Visit(SqlIdentifierPathExpression sqlObject) { this.tokens.Add(sqlObject.Value.Value); sqlObject.ParentPath?.Accept(this); return(this.tokens); }