Nickolay Ponomarev
f87e8d5158
Don't duplicate all the parse_simple_select assertions in the LIMIT test
2019-06-17 00:39:00 +03:00
Nickolay Ponomarev
3c073a4c34
Use TableAlias in Cte
2019-06-16 21:18:57 +03:00
Nickolay Ponomarev
4f239745bc
Update comments now that get_precedence is no more
2019-06-16 21:01:29 +03:00
Nickolay Ponomarev
dc26c4abd5
Merge pull request #115 from nickolay/pr/followups
...
Doc improvements and follow-ups to the recent PRs
2019-06-15 01:57:52 +03:00
Nikhil Benesch
98a06d6d23
Merge pull request #111 from benesch/join-tweaks
...
Refine join parsing
2019-06-14 16:45:06 -04:00
Nickolay Ponomarev
535505bb96
Update the error message in parse_query_body
2019-06-14 16:28:53 -04:00
Nikhil Benesch
4ee461bae4
Require that nested joins always have one join
...
The SQL specification prohibits constructions like
SELECT * FROM a NATURAL JOIN (b)
where b sits alone inside parentheses. Parentheses in a FROM entry
always introduce either a derived table or a join.
2019-06-14 16:28:52 -04:00
Nikhil Benesch
8bee74277a
Handle derived tables with set operations
...
This commit adds support for derived tables (i.e., subqueries) that
incorporate set operations, like:
SELECT * FROM (((SELECT 1) UNION (SELECT 2)) t1 AS NATURAL JOIN t2)
This introduces a bit of complexity around determining whether a left
paren starts a subquery, starts a nested join, or belongs to an
already-started subquery. The details are explained in a comment within
the patch.
2019-06-14 16:28:52 -04:00
Nickolay Ponomarev
5c7ff79e78
Add a test for parsing the NULL literal
...
(Coveralls notices we didn't have one.)
2019-06-13 11:17:36 +03:00
Nickolay Ponomarev
45c9aa1cc2
Use self.expected() more
2019-06-13 11:15:10 +03:00
Nickolay Ponomarev
f18fbe5cda
Remove unused parse_literal_double
...
`parse_value` handles parsing a non-integer value in expression context,
and we use parse_literal_uint() when expecting a number in other
contexts (such as `FETCH FIRST ... ROWS`)
2019-06-13 11:11:23 +03:00
Nickolay Ponomarev
7041850b33
Reduce nesting in parse_table_and_joins
...
This is a follow-up to #109 which moved the handling of Token::Comma
from parse_table_and_joins to the `FROM` parser.
2019-06-13 04:30:14 +03:00
Nickolay Ponomarev
32cf36e64f
Add a testcase, which passes thanks to PR #109
2019-06-12 21:04:31 +03:00
Nickolay Ponomarev
6b0a396785
Remove table_key.rs accidentally re-added in PR #79
2019-06-12 21:04:31 +03:00
Nickolay Ponomarev
cfb77912f7
Mention SQLSelectItem::Wildcard in ASTNode::SQLWildcard docs
...
as a follow-up to https://github.com/andygrove/sqlparser-rs/issues/52
2019-06-12 21:04:31 +03:00
Nickolay Ponomarev
846f2ff1d9
Fix intra_doc_link_resolution_failure in cargo doc
...
..and other formatting errors.
2019-06-12 21:04:27 +03:00
Nickolay Ponomarev
26fac099b1
Update Value docs
2019-06-12 21:04:23 +03:00
Andy Grove
1998910bfa
Merge pull request #113 from andygrove/revert-78-visitor
...
Revert "Add an AST visitor"
2019-06-10 21:56:42 -06:00
Andy Grove
b07c7a90f1
Revert "Add an AST visitor"
2019-06-10 21:51:10 -06:00
Andy Grove
7ed6e03880
Merge pull request #78 from benesch/visitor
...
Add an AST visitor
2019-06-10 21:19:45 -06:00
Nikhil Benesch
f2fda57e36
Merge pull request #112 from benesch/expr-consistency
...
Improve consistency of binary/unary op nodes
2019-06-10 23:08:33 -04:00
Nikhil Benesch
ae25dce246
Split operators by arity
...
It is useful downstream to have two separate enums, one for unary
operators and one for binary operators, so that the compiler can check
exhaustiveness. Otherwise downstream consumers need to manually encode
which operators are unary and which operators are binary when matching
on an Operator enum.
2019-06-10 23:03:11 -04:00
Nikhil Benesch
9e33cea9b8
Standardize BinaryOp and UnaryOp nodes
...
These were previously called "BinaryExpr" and "Unary"; besides being
inconsistent, it's also not correct to say "binary expression" or "unary
expression", as it's the operators that have arities, not the
expression. Adjust the naming of the variants accordingly.
2019-06-10 23:02:17 -04:00
Andy Grove
b379480b7a
Merge pull request #79 from benesch/license
...
Standardize license headers
2019-06-10 19:39:12 -06:00
Nikhil Benesch
5896f01ce0
Merge pull request #109 from benesch/implicit-join-fix
...
Properly handle mixed implicit and explicit joins
2019-06-10 11:17:01 -04:00
Nikhil Benesch
ce171c2a3d
Support VALUES and parenthesized SELECTs as top-level statements
2019-06-10 11:11:26 -04:00
Nikhil Benesch
b841dccc2c
Properly handle mixed implicit and explicit joins
...
Parse a query like
SELECT * FROM a NATURAL JOIN b, c NATURAL JOIN d
as the SQL specification requires, i.e.:
from: [
TableReference {
relation: TableFactor::Table("a"),
joins: [Join {
relation: TableFactor::Table("b"),
join_operator: JoinOperator::Natural,
}]
},
TableReference {
relation: TableFactor::Table("c"),
joins: [Join {
relation: TableFactor::Table("d"),
join_operator: JoinOperator::Natural,
}]
}
]
Previously we were parsing such queries as
relation: TableFactor::Table("a"),
joins: [
Join {
relation: TableFactor::Table("b"),
join_operator: JoinOperator::Natural,
},
Join {
relation: TableFactor::Table("c"),
join_operator: JoinOperator::Implicit,
},
Join {
relation: TableFactor::Table("d"),
join_operator: JoinOperator::Natural,
},
]
which did not make the join hierarchy clear.
2019-06-10 11:11:25 -04:00
Nickolay Ponomarev
518c8833d2
Merge pull request #110 from nickolay/pr/cleanups
...
Minor code clean-ups
2019-06-09 20:24:13 +03:00
Nikhil Benesch
2d1e05e21d
Merge pull request #103 from benesch/intervals
...
Support interval literals
2019-06-09 12:41:57 -04:00
Nikhil Benesch
2798ddf5fd
Support interval literals
2019-06-09 12:37:57 -04:00
Nickolay Ponomarev
99768711dc
Fix redundant closures in tests
...
We don't have the tests checked by clippy on CI, despite [passing the
`--all-targets`](5536cd1f9e/.travis.yml (L46)
),
but VSCode+RLS display warnings for these.
See: https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure
2019-06-09 17:05:19 +03:00
Nickolay Ponomarev
b6dac5099d
Use the same pattern to parse comma-separated lists of things
2019-06-09 16:47:02 +03:00
Nickolay Ponomarev
ab88e02f0d
Raise a TokenizerError when a delimited identifier is not closed before EOF
2019-06-09 16:42:23 +03:00
Nickolay Ponomarev
20637f0327
Introduce peeking_take_while to simplify tokenizer
...
I could probably look into using an existing crate like
https://github.com/fitzgen/peeking_take_while - but as a small helper
works as well I didn't have the reason to.
2019-06-09 16:42:23 +03:00
Nickolay Ponomarev
ebc5efda98
Reduce duplication in tokenizer by matching on Some('...') directly
2019-06-09 16:42:23 +03:00
Nikhil Benesch
5536cd1f9e
Merge pull request #106 from offscale/transactions
...
Transaction support
2019-06-09 01:35:05 -04:00
Nikhil Benesch
7e96d81b47
Merge pull request #93 from benesch/col-constr-order
...
Parse column constraints in any order
2019-06-09 00:36:51 -04:00
Agustin Chiappe Berrini
582b25add6
Add basic support for transaction statements
...
Co-authored-by: Samuel Marks <807580+SamuelMarks@users.noreply.github.com>
Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
2019-06-09 00:36:20 -04:00
Nikhil Benesch
4a5099fdba
Merge pull request #108 from benesch/test-nesting
...
Test that redundant nesting is supported
2019-06-09 00:28:44 -04:00
Nikhil Benesch
ffa1c8f853
Parse column constraints in any order
...
CREATE TABLE t (a INT NOT NULL DEFAULT 1 PRIMARY KEY) is as valid as
CREATE TABLE t (a INT DEFAULT 1 PRIMARY KEY NOT NULL).
2019-06-08 12:13:55 -04:00
Nikhil Benesch
ccbd048dda
Test that redundant nesting is supported
...
SELECT * FROM (((SELECT 1))) is just as valid as
SELECT * FROM (SELECT 1). Add a test to ensure that we can parse the
first form.
Addresses a comment from #100 .
2019-06-07 23:54:56 -04:00
Nikhil Benesch
5f9f17de8a
Merge pull request #100 from benesch/nested-joins
...
Support nested joins
2019-06-07 22:37:53 -04:00
Nikhil Benesch
fc5e662b91
Merge pull request #107 from benesch/prec
...
Fix precedence of unary NOT
2019-06-06 17:26:00 -04:00
Nikhil Benesch
525f4d7501
Fix precedence of unary NOT
...
get_next_precedence deals with left-binding power, not right binding
power. Therefore, when it encounters a standalone NOT operator (i.e., a
"NOT" token that is not followed by "BETWEEN", "LIKE", or "IN"), it
should return 0, because unary NOT is not an infix operator, it's a
prefix operator, and therefore it has no left-binding power.
2019-06-06 17:20:07 -04:00
Nikhil Benesch
ee49af3f52
Add an AST visitor
2019-06-05 14:06:45 -04:00
Nikhil Benesch
e78cf0483e
Standardize license headers
...
Standardize the license header, removing the Grove Enterprise copyright
notice where it exists per #58 . Also add a CI check to ensure that files
without license headers don't get merged.
Fix #58 .
2019-06-04 10:54:12 -04:00
Nikhil Benesch
8fbf82deb0
Support nested joins
...
Fix #83 .
2019-06-04 10:25:07 -04:00
Nikhil Benesch
1f87083906
Merge pull request #99 from benesch/dates
...
Basic date/time support
2019-06-04 00:30:21 -04:00
Nikhil Benesch
ed3ed26bb1
Support parsing dates, times, and timestamps as strings
2019-06-04 00:12:09 -04:00
Nikhil Benesch
11fc833433
Merge pull request #96 from benesch/extract
...
Support EXTRACT function-like operator
2019-06-04 00:07:23 -04:00