Commit graph

432 commits

Author SHA1 Message Date
Nickolay Ponomarev
e5c0c426b7 Simplify parse_infix()
- ASTNode::SQLBinaryExpr is now constructed in one location
- There's no duplicate calls to parse_in/parse_between
- The list of tokens that correspond to operators is not duplicated
  in parse_infix / to_sql_operator
- ...which made it easy to distinguish between errors that could be
  caused by invalid input and internal errors. I switched the latter
  to `panic!()`
2019-04-27 21:14:18 +03:00
Nickolay Ponomarev
d65274bc31 Improve ALTER error messages for unsupported syntax 2019-04-27 21:14:18 +03:00
Nickolay Ponomarev
787cd9a717 Add Parser::expected() for more succinct error handling 2019-04-27 21:14:18 +03:00
Nickolay Ponomarev
c679c7a5b4 Remove Value::Uuid
We don't have the code to parse UUID literals, so it's dead code, that
brings in the dependency on `uuid`.

I kept SQLType::Uuid, as it's not dead code, though it ought to be
dialect-specific.
2019-04-27 21:14:18 +03:00
Nickolay Ponomarev
6bb2acc9f8
Merge pull request #50 from nickolay/window-functions
Support OVER clause for window/analytic functions, add support for qualified function names
2019-04-27 21:12:08 +03:00
Andy Grove
64b1ea7a25
Merge pull request #54 from nickolay/windows-newlines
Support \r and \r\n line breaks in tokenizer
2019-04-27 08:54:20 -06:00
Andy Grove
07d66a93ef
Merge pull request #53 from thomas-jeepe/master
Fix qualified wildcard stringifying
2019-04-27 08:53:08 -06:00
Nickolay Ponomarev
bf3110f6ce Use consume_and_return when possible 2019-04-27 02:51:10 +03:00
Nickolay Ponomarev
6f44494910 Support \r and \r\n line breaks in tokenizer 2019-04-26 02:53:39 +03:00
Justin Haug
80aceba630 run cargo fmt 2019-04-22 17:50:12 -04:00
Justin Haug
80dccf6885 Add support for escaping single quote strings 2019-04-22 13:32:05 -04:00
Justin Haug
5b464e6b1a Fix qualified wildcard stringifying 2019-04-22 13:10:29 -04:00
Nickolay Ponomarev
098d1c4a17 Enable clippy lints by default in RLS 2019-04-21 04:46:19 +03:00
Nickolay Ponomarev
50a2310173 Rename SQLStatement::SQLSelect to SQLQuery
The name was confusing:
SQLStatement::SQLSelect(
  SQLQuery {
    body: SQLSetExpr::Select(SQLSelect)
  }
)

Fix the `large_enum_variant` clippy lint for `SQLStatement::SQLQuery`
`SQLStatement::SQLCreateView`, and `SQLSetExpr::Select`, while we're
changing the AST anyway
https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
2019-04-21 04:46:19 +03:00
Nickolay Ponomarev
a3a8626e6b Fix a clippy lint and reduce duplication in SQLType::to_string() 2019-04-21 04:46:19 +03:00
Nickolay Ponomarev
c223eaf0aa Fix a bunch of trivial clippy lints 2019-04-21 04:46:19 +03:00
Nickolay Ponomarev
3df2223d95 Fix clippy if_same_then_else lint
https://rust-lang.github.io/rust-clippy/master/#if_same_then_else

There was a bug in parsing `TIME` (not followed by {WITH | WITHOUT}
TIME ZONE) -- that parsed as SQLType::Timestamp instead of SQLType::Time
2019-04-21 04:41:11 +03:00
Nickolay Ponomarev
0634ec4a83 Apply suggestions from cargo fix --edition-idioms 2019-04-21 04:41:11 +03:00
Nickolay Ponomarev
b12a19e197 Switch to the Rust 2018 edition
This requires Rust 1.31 (from last year) to build, but is otherwise
compatible with the 2015-edition code.
2019-04-21 04:41:11 +03:00
Nickolay Ponomarev
9a244e059e Fix clippy lints in "Support qualified function names" 2019-04-21 02:05:36 +03:00
Nickolay Ponomarev
de057deff6 Fix clippy lints in comma_separated_string 2019-04-21 02:05:36 +03:00
Nickolay Ponomarev
085e8a6b04 Use named fields in ExpressionWithAlias instead of a tuple
(This produces more natural JSON representation when serializing AST
with serde.)
2019-04-20 22:51:29 +03:00
Nickolay Ponomarev
4a5dc8dd4b Support qualified function names
...e.g. `db.schema.func()`
2019-04-20 22:51:29 +03:00
Nickolay Ponomarev
d4de248c73 Support OVER clause for window/analytic functions
Since this changes SQLFunction anyway, changed its `id` field to `name`,
as we don't seem to use "id" to mean "name" anywhere else.
2019-04-20 22:51:29 +03:00
Nickolay Ponomarev
c8e7c3b343 Introduce comma_separated_string() to reduce boilerplate in ToString impls 2019-04-20 22:51:29 +03:00
Nickolay Ponomarev
bbf1805729 Support SELECT DISTINCT 2019-04-20 14:21:26 +03:00
Nickolay Ponomarev
31b6076d05 Use the same order in #[derive()] for all AST types
(So that adding another trait can be done with a global search and replace.)
2019-04-20 14:21:26 +03:00
Nickolay Ponomarev
e113dee7e8 Fix error text for unexpected token after NOT 2019-04-20 14:21:26 +03:00
Nickolay Ponomarev
5263ee1e9e Reduce nesting of ifs in SQLType::Decimal::to_string() 2019-04-20 14:21:26 +03:00
Nickolay Ponomarev
451513db5b Simplify parse_function() 2019-04-20 14:21:26 +03:00
Zhiyuan Zheng
d8f824c400 merge CreateExternalTable & CreateTable. 2019-04-14 01:05:26 +08:00
Zhiyuan Zheng
26940920ac Add unit tests. 2019-04-09 13:28:01 +08:00
Zhiyuan Zheng
f0f6082eff support create external table 2019-04-08 21:36:02 +08:00
Nickolay Ponomarev
f30ab89ad2 Re-run cargo fmt 2019-03-08 15:46:40 +03:00
Nikhil Benesch
23a0fc79f5
Support CREATE MATERIALIZED VIEW 2019-03-07 13:14:33 -05:00
Nickolay Ponomarev
52e0f55b6f Support UNION/EXCEPT/INTERSECT 2019-02-11 05:14:36 +03:00
Nickolay Ponomarev
533775c0da Support CHAR synonym for CHARACTER
https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#character-string-type
2019-02-11 05:14:34 +03:00
Nickolay Ponomarev
23a0d032bd Support NUMERIC without precision or scale
https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#exact-numeric-type
2019-02-11 05:13:48 +03:00
Nickolay Ponomarev
54c9ca8619 Support unary + / - 2019-02-11 05:13:48 +03:00
Nickolay Ponomarev
786b1cf18a Support BETWEEN 2019-02-11 05:13:48 +03:00
Nickolay Ponomarev
264319347d Support IN 2019-02-11 05:13:48 +03:00
Nickolay Ponomarev
bed03abe44 Support AS and qualified wildcards in SELECT 2019-02-11 05:13:48 +03:00
Nickolay Ponomarev
bf0c07bb1b Support basic CTEs (WITH)
Some unsupported features are noted as TODOs.
2019-02-11 05:13:48 +03:00
Nickolay Ponomarev
f958e9d3cf TBD fixup multiline comment tokenization 2019-02-11 05:13:48 +03:00
Nickolay Ponomarev
028c613c3f Support comments in the tokenizer 2019-02-07 05:34:38 +03:00
Nickolay Ponomarev
35dd9342e2 Support national string literals (N'...')
Widely used in MS SQL and specified in ANSI.
2019-02-07 05:34:33 +03:00
Nickolay Ponomarev
b9f4b503b6 Support different quoting styles for delimited identifiers
The dialect information is from https://en.wikibooks.org/wiki/SQL_Dialects_Reference/Data_structure_definition/Delimited_identifiers
2019-02-07 05:34:29 +03:00
Nickolay Ponomarev
b3693bfa63 Simplify quoted identifier tokenization 2019-02-07 05:34:26 +03:00
Nickolay Ponomarev
0c0cbcaff4 Support basic CREATE VIEW 2019-02-07 05:34:12 +03:00
Nickolay Ponomarev
346d1ff2e4 Improve error messages in parse_create()
By not swallowing the Err from parse_data_type().

Also switch to `match` to enable parsing table-level constraints in this
loop later.
2019-02-07 05:34:09 +03:00