Skip to content

Commit

Permalink
The AS key word is optional noise.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrattli committed Apr 24, 2021
1 parent fa40841 commit a12f633
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/NpgsqlFSharpParser/Parser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ let optionalFrom =
optionalExpr (
attempt (
text "FROM " >>. simpleIdentifier >>= fun table ->
text "AS" >>= fun _ ->
optional (text "AS") >>= fun _ ->
simpleIdentifier >>= fun alias ->
preturn (Expr.As(Expr.Ident table, Expr.Ident alias))
)
Expand Down
6 changes: 6 additions & 0 deletions tests/NpgsqlFSharpAnalyzer.Tests/ParseSelectTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ let selectQueryTests = testList "Parse SELECT tests" [
From = Some (Expr.As(Expr.Ident "users", Expr.Ident "u"))
}

testSelect "SELECT COUNT(*) AS user_count FROM users u" {
SelectExpr.Default with
Columns = [Expr.As(Expr.Function("COUNT", [Expr.Star]), Expr.Ident("user_count")) ]
From = Some (Expr.As(Expr.Ident "users", Expr.Ident "u"))
}

testSelect "SELECT COUNT(*) FROM users LIMIT 10" {
SelectExpr.Default with
Columns = [Expr.Function("COUNT", [Expr.Star]) ]
Expand Down

0 comments on commit a12f633

Please sign in to comment.