public void TestSelectStarFromTableWithAlias() { StatementList statementList = new StatementList() { Statements = new List <Statement>() { new SelectStatement() { SelectElements = new List <Expressions.SelectExpression>() { new SelectStarExpression() }, FromClause = new Clauses.FromClause() { TableReference = new FromTableReference() { TableName = "test", Alias = "t" } } } } }; var expected = "SELECT * FROM test t"; var actual = statementList.Print(); actual.Should().Be(expected); }
public string Print(string prefix) { if (_elseBranchStatements != null) { return(string.Format("If ({0}) Then\n {1} Else {2}", _conditionExpr.Print(prefix), _ifBranchStatements.Print(prefix), _elseBranchStatements.Print(prefix))); } return(string.Format("If ({0}) Then\n {1}", _conditionExpr.Print(prefix), _ifBranchStatements.Print(prefix))); }
public string Print(string prefix) { if (_elseBranchStatements != null) { return(string.Format("Case ({0}) Then\n {1} Else {2}", _conditionExpr.Print(prefix), String.Join("\n", _whenBranchStatements.Select(x => String.Format("WHEN {0}: {1}", x.Key.Print(prefix), x.Value.Print(prefix)))), _elseBranchStatements.Print(prefix))); } return(string.Format("If ({0}) Then\n {1}", _conditionExpr.Print(prefix), String.Join("\n", _whenBranchStatements.Select(x => String.Format("WHEN {0}: {1}", x.Key.Print(prefix), x.Value.Print(prefix)))))); }
public void TestSelectBinaryBitwiseSubtract() { StatementList statementList = GetBinaryTestStructure(BinaryType.Subtract); var expected = "SELECT c1 - 'a'"; var actual = statementList.Print(); actual.Should().Be(expected); }
public void TestSelectWhereComparison() { StatementList statementList = new StatementList() { Statements = new List <Statement>() { new SelectStatement() { SelectElements = new List <Expressions.SelectExpression>() { new SelectStarExpression() }, FromClause = new Clauses.FromClause() { TableReference = new FromTableReference() { TableName = "test" } }, WhereClause = new Clauses.WhereClause() { Expression = new BooleanComparisonExpression() { Left = new ColumnReference() { Identifiers = new List <string>() { "c1" } }, Right = new StringLiteral() { Value = "a" }, Type = BooleanComparisonType.Equals } } } } }; var expected = "SELECT * FROM test WHERE c1 = 'a'"; var actual = statementList.Print(); actual.Should().Be(expected); }
public void TestSelecColumnsWithAlias() { StatementList statementList = new StatementList() { Statements = new List <Statement>() { new SelectStatement() { SelectElements = new List <Expressions.SelectExpression>() { new SelectScalarExpression() { Expression = new ColumnReference() { Identifiers = new List <string>() { "c1" } }, Alias = "a" }, new SelectScalarExpression() { Expression = new ColumnReference() { Identifiers = new List <string>() { "c2" } }, Alias = "b" } } } } }; var expected = "SELECT c1 AS a, c2 AS b"; var actual = statementList.Print(); actual.Should().Be(expected); }
public void TestSelectStar() { StatementList statementList = new StatementList() { Statements = new List <Statement>() { new SelectStatement() { SelectElements = new List <Expressions.SelectExpression>() { new SelectStarExpression() } } } }; var expected = "SELECT *"; var actual = statementList.Print(); actual.Should().Be(expected); }
public string Print(string prefix) { return(String.Format("{0}FOR {1} IN {2}\n{3}\n{4}", prefix, _var, _value.Print(""), _attributes.Print(prefix + ": "), _statements.Print(prefix + " "))); }
public string Print(string prefix) { return(prefix + String.Format("CAPTURE {0}\n{1}", _var, _captureList.Print(prefix + " "))); }
public string Print(string prefix) { return(prefix + String.Format("TableRow {0} IN {1}\n{2}\n{3}", _var, _value.Print(""), _attributes.Print(prefix + ": "), _statements.Print(prefix + " "))); }