Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/SqlParser.Tests/CoverageTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public void Top_Renders_Sql()
{
//ar top = new Top(new Expression.LiteralValue(new Value.Number("1")), false, false);
var top = new Top(new TopQuantity.TopExpression(new Expression.LiteralValue(new Value.Number("1"))), false, false);

Assert.Equal("TOP (1)", top.ToSql());
}

Expand Down
10 changes: 5 additions & 5 deletions src/SqlParser.Tests/Dialects/BigQueryDialectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void Parse_Join_Constraint_Unnest_Alias()
{
new (new TableFactor.UnNest([new CompoundIdentifier(new Ident[] { "t1", "a" })])
{
Alias = new TableAlias("f"),
Alias = new TableAlias("f", true),
},
new JoinOperator.Inner(new JoinConstraint.On(
new BinaryOp(
Expand Down Expand Up @@ -442,12 +442,12 @@ public void Parse_Typeless_Struct_Syntax()
Assert.Equal(expected, select.Projection.Skip(2).First().AsExpr());

expected = new Struct([
new Named(new LiteralValue(new Value.Number("1")), "a"),
new Named(new LiteralValue(new Value.SingleQuotedString("abc")), "b")
new Named(new LiteralValue(new Value.Number("1")), "a", true),
new Named(new LiteralValue(new Value.SingleQuotedString("abc")), "b", true)
], []);
Assert.Equal(expected, select.Projection.Skip(3).First().AsExpr());

expected = new Struct([new Named(new Identifier("str_col"), "abc")], []);
expected = new Struct([new Named(new Identifier("str_col"), "abc", true)], []);
Assert.Equal(expected, select.Projection.Skip(4).First().AsExpr());
}

Expand Down Expand Up @@ -769,7 +769,7 @@ CREATE VIEW myproject.mydataset.newview
var create = VerifiedStatement<Statement.CreateView>(sql);
var columns = new Sequence<ViewColumnDef>
{
new("name"),
new("name"),
new("age", Options: [new ColumnOption.Options([new SqlOption.KeyValue("description", new LiteralValue(new Value.DoubleQuotedString("field age")))])])
};
Assert.Equal(new ObjectName(["myproject", "mydataset", "newview"]), create.Name);
Expand Down
2 changes: 1 addition & 1 deletion src/SqlParser.Tests/Dialects/HiveDialectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ public void Parse_Create_Function()
[Fact]
public void Filter_As_Alias()
{
OneStatementParsesTo("SELECT name filter FROM region", "SELECT name AS filter FROM region");
OneStatementParsesTo("SELECT name filter FROM region", "SELECT name filter FROM region");
}

[Fact]
Expand Down
4 changes: 2 additions & 2 deletions src/SqlParser.Tests/Dialects/MsSqlDialectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public void Parse_MsSql_Single_Quoted_Identifiers()
{
DefaultDialects = [new MsSqlDialect(), new GenericDialect()];

OneStatementParsesTo("SELECT foo 'alias'", "SELECT foo AS 'alias'");
OneStatementParsesTo("SELECT foo 'alias'", "SELECT foo 'alias'");
}

[Fact]
public void Parse_MsSql_Delimited_Identifiers()
{
OneStatementParsesTo(
"SELECT [a.b!] [FROM] FROM foo [WHERE]",
"SELECT [a.b!] AS [FROM] FROM foo AS [WHERE]");
"SELECT [a.b!] [FROM] FROM foo [WHERE]");
}

[Fact]
Expand Down
8 changes: 4 additions & 4 deletions src/SqlParser.Tests/Dialects/MySqlDialectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,14 +496,14 @@ public void Parse_Update_With_Joins()

var table = new TableWithJoins(new TableFactor.Table("orders")
{
Alias = new TableAlias("o")
Alias = new TableAlias("o", true)
})
{
Joins = new Join[]
{
new(new TableFactor.Table("customers")
{
Alias = new TableAlias("c")
Alias = new TableAlias("c", true)
})
{
JoinOperator = new JoinOperator.Inner(new JoinConstraint.On(new BinaryOp(
Expand Down Expand Up @@ -1090,7 +1090,7 @@ public void Parse_Json_Table()
new JsonTableColumnErrorHandling.Null()))
])
{
Alias = new TableAlias("t")
Alias = new TableAlias("t", true)
};

Assert.Equal(expected, joinTable.From![0].Relation);
Expand All @@ -1114,7 +1114,7 @@ public void Parse_Create_Table_With_Column_Collate()
[Fact]
public void Parse_Lock_Tables()
{
OneStatementParsesTo("LOCK TABLES trans t READ, customer WRITE", "LOCK TABLES trans AS t READ, customer WRITE");
OneStatementParsesTo("LOCK TABLES trans t READ, customer WRITE", "LOCK TABLES trans t READ, customer WRITE");

//VerifiedStatement("LOCK TABLES trans AS t READ, customer WRITE");
//VerifiedStatement("LOCK TABLES trans AS t READ LOCAL, customer WRITE");
Expand Down
12 changes: 6 additions & 6 deletions src/SqlParser.Tests/Dialects/PostgresDialectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,8 @@ public void Parse_Pg_Returning()

var expected = new SelectItem[]
{
new SelectItem.ExpressionWithAlias(new Identifier("temp_lo"), "lo"),
new SelectItem.ExpressionWithAlias(new Identifier("temp_hi"), "hi"),
new SelectItem.ExpressionWithAlias(new Identifier("temp_lo"), "lo", true),
new SelectItem.ExpressionWithAlias(new Identifier("temp_hi"), "hi", true),
new SelectItem.UnnamedExpression(new Identifier("prcp"))
};

Expand Down Expand Up @@ -1792,7 +1792,7 @@ public void Parse_Delimited_Identifiers()

var table = new TableFactor.Table(new ObjectName(new Ident("a table", Symbols.DoubleQuote)))
{
Alias = new TableAlias(new Ident("alias", Symbols.DoubleQuote))
Alias = new TableAlias(new Ident("alias", Symbols.DoubleQuote), true)
};

Assert.Equal(table, select.From!.Single().Relation);
Expand All @@ -1809,7 +1809,7 @@ public void Parse_Delimited_Identifiers()

Assert.Equal(new SelectItem.ExpressionWithAlias(new Identifier(
new Ident("simple id", Symbols.DoubleQuote)),
new Ident("column alias", Symbols.DoubleQuote)),
new Ident("column alias", Symbols.DoubleQuote), true),
select.Projection[2]);

VerifiedStatement("CREATE TABLE \"foo\" (\"bar\" \"int\")");
Expand Down Expand Up @@ -1921,7 +1921,7 @@ public void Parse_Dollar_Quoted_String()
Assert.Equal(new LiteralValue(new Value.DollarQuotedString(new DollarQuotedStringValue("hello"))), projection[0].AsExpr());
Assert.Equal(new LiteralValue(new Value.DollarQuotedString(new DollarQuotedStringValue("world", "tag_name"))), projection[1].AsExpr());
Assert.Equal(new LiteralValue(new Value.DollarQuotedString(new DollarQuotedStringValue("Foo$Bar"))), projection[2].AsExpr());
var expr = new SelectItem.ExpressionWithAlias(new LiteralValue(new Value.DollarQuotedString(new DollarQuotedStringValue("Foo$Bar"))), "col_name");
var expr = new SelectItem.ExpressionWithAlias(new LiteralValue(new Value.DollarQuotedString(new DollarQuotedStringValue("Foo$Bar"))), "col_name", false);
Assert.Equal(expr, projection[3]);
Assert.Equal(new LiteralValue(new Value.DollarQuotedString(new DollarQuotedStringValue(""))), projection[4].AsExpr());
Assert.Equal(new LiteralValue(new Value.DollarQuotedString(new DollarQuotedStringValue("", "tag_name"))), projection[5].AsExpr());
Expand Down Expand Up @@ -2085,7 +2085,7 @@ public void Parse_Join_Constraint_Unnest_Alias()
{
new (new TableFactor.UnNest([new CompoundIdentifier(new Ident[] { "t1", "a" })])
{
Alias = new TableAlias("f"),
Alias = new TableAlias("f", true),
},
new JoinOperator.Inner(new JoinConstraint.On(
new BinaryOp(
Expand Down
2 changes: 1 addition & 1 deletion src/SqlParser.Tests/Dialects/RedshiftDialectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void Parse_Delimited_Identifiers()

var table = new TableFactor.Table(new ObjectName(new Ident("a table", Symbols.DoubleQuote)))
{
Alias = new TableAlias(new Ident("alias", Symbols.DoubleQuote))
Alias = new TableAlias(new Ident("alias", Symbols.DoubleQuote), true)
};

Assert.Equal(table, select.From!.Single().Relation);
Expand Down
16 changes: 8 additions & 8 deletions src/SqlParser.Tests/Dialects/SnowflakeDialectTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,25 +104,25 @@ public void Test_Single_Table_In_Parenthesis_With_Alias()

OneStatementParsesTo(
"SELECT * FROM (a NATURAL JOIN (b) c )",
"SELECT * FROM (a NATURAL JOIN b AS c)");
"SELECT * FROM (a NATURAL JOIN b c)");
OneStatementParsesTo(
"SELECT * FROM (a NATURAL JOIN ((b)) c )",
"SELECT * FROM (a NATURAL JOIN b AS c)");
"SELECT * FROM (a NATURAL JOIN b c)");
OneStatementParsesTo(
"SELECT * FROM (a NATURAL JOIN ( (b) c ) )",
"SELECT * FROM (a NATURAL JOIN b AS c)");
"SELECT * FROM (a NATURAL JOIN b c)");
OneStatementParsesTo(
"SELECT * FROM (a NATURAL JOIN ( (b) as c ) )",
"SELECT * FROM (a NATURAL JOIN b AS c)");
OneStatementParsesTo(
"SELECT * FROM (a alias1 NATURAL JOIN ( (b) c ) )",
"SELECT * FROM (a AS alias1 NATURAL JOIN b AS c)");
"SELECT * FROM (a alias1 NATURAL JOIN b c)");
OneStatementParsesTo(
"SELECT * FROM (a as alias1 NATURAL JOIN ( (b) as c ) )",
"SELECT * FROM (a AS alias1 NATURAL JOIN b AS c)");
OneStatementParsesTo(
"SELECT * FROM (a NATURAL JOIN b) c",
"SELECT * FROM (a NATURAL JOIN b) AS c");
"SELECT * FROM (a NATURAL JOIN b) c");

DefaultDialects = [new SnowflakeDialect()];
var ex = Assert.Throws<ParserException>(() => ParseSqlStatements("SELECT * FROM (a b) c"));
Expand Down Expand Up @@ -259,7 +259,7 @@ public void Parse_Delimited_Identifiers()

var table = new TableFactor.Table(new ObjectName(new Ident("a table", Symbols.DoubleQuote)))
{
Alias = new TableAlias(new Ident("alias", Symbols.DoubleQuote))
Alias = new TableAlias(new Ident("alias", Symbols.DoubleQuote), true)
};

Assert.Equal(table, select.From!.Single().Relation);
Expand Down Expand Up @@ -1083,14 +1083,14 @@ ASOF JOIN quotes_unixtime AS qu

var expected = new TableWithJoins(new TableFactor.Table("trades_unixtime")
{
Alias = new TableAlias("tu")
Alias = new TableAlias("tu", true)
})
{
Joins =
[
new Join(new TableFactor.Table("quotes_unixtime")
{
Alias = new TableAlias("qu")
Alias = new TableAlias("qu", true)
},
new JoinOperator.AsOf(new BinaryOp(
new CompoundIdentifier(["tu", "trade_time"]),
Expand Down
Loading