Nickolay Ponomarev
5047f2c02e
Remove the ansi-specific test file and update PG tests
...
- The ANSI dialect is now tested in `sqlparser_common.rs`
- Some PG testcases are also parsed by the generic dialect successfully,
so test that.
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
1347ca0825
Move the rest of tests not specific to PG from the sqlparser_postgres.rs
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
478dbe940d
Factor test helpers into a common module
...
Also run "generic" tests with all dialects (`parse_select_version`
doesn't work with ANSI dialect, so I moved it to the postgres file
temporarily)
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
de177f107c
Remove dead datetime-related code
...
1) Removed unused date/time parsing methods from `Parser`
I don't see how the token-based parsing code would ever be used: the
date/time literals are usually quoted, like `DATE 'yyyy-mm-dd'` or
simply `'YYYYMMDD'`, so the date will be a single token.
2) Removed unused date/time related variants from `Value` and the
dependency on `chrono`.
We don't support parsing date/time literals at the moment and when we
do I think we should store the exact String to let the consumer parse
it as they see fit.
3) Removed `parse_timestamps_example` and
`parse_timestamps_with_millis_example` tests. They parsed as
`number(2016) minus number(02) minus number(15) <END OF EXPRESSION>`
(leaving the time part unparsed) as it makes no sense to try parsing
a yyyy-mm-dd value as an SQL expression.
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
9297ffbe18
Move tests using standard SQL from the postgresql-specific file
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
d1b088bd43
Switch remaining tests to the standard format
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
0233604f9b
Remove extraneous tests
...
`parse_example_value` parses as compound identifier, which makes no
sense ("SARAH"."LEWISE@sakilacustomer"."org")
`parse_function_now` is unnecessary since we already test the parsing
of functions in `parse_scalar_function_in_projection`
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
fe635350f0
Improve INSERT tests
...
De-duplicate and check for specific error in `parse_insert_invalid`.
2019-05-04 01:00:13 +03:00
Nickolay Ponomarev
d58bbb8f9f
Update doc comments
...
(The `SQLBetween` change is to fix a `cargo doc` warning.)
2019-05-02 21:30:32 +03:00
Andy Grove
4b27db0bf9
Merge pull request #59 from nickolay/next
...
Cleanups, and support `CASE operand`, TVFs and MSSQL-specific WITH hints
2019-04-27 15:13:47 -06:00
Nickolay Ponomarev
364f62f333
Parse table-valued functions and MSSQL-specific WITH hints
...
1) Table-valued functions (`FROM possibly_qualified.fn(arg1, ...)`) is
not part of ANSI SQL, but is supported in Postgres and MSSQL at least:
- "38.5.7. SQL Functions as Table Sources" <https://www.postgresql.org/docs/current/xfunc-sql.html#XFUNC-SQL-TABLE-FUNCTIONS >
- `user_defined_function` in "FROM (Transact-SQL)" <https://docs.microsoft.com/en-us/sql/t-sql/queries/from-transact-sql?view=sql-server-2017 >
I've considered renaming TableFactor::Table to something else (Object?),
now that it can be a TVF, but couldn't come up with a satisfactory name.
2) "WITH hints" is MSSQL-specific syntax
<https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table?view=sql-server-2017 >
Note that MSSQL supports the following ways of specifying hints, which
are parsed with varying degrees of accuracy:
- `FROM tab (NOLOCK)` -- deprecated syntax, parsed as a function with a `NOLOCK` argument
- `FROM tab C (NOLOCK)` -- deprecated syntax, rejected ATM
- `FROM TAB C WITH (NOLOCK)` -- OK
2019-04-27 21:14:18 +03:00
Nickolay Ponomarev
e5e3d71354
Support CASE operand WHEN expected_value THEN ..
...
Another part of #15
2019-04-27 21:14:18 +03:00
Nickolay Ponomarev
2aa4c267e7
Simplify CASE parsing
2019-04-27 21:14:18 +03:00
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
Andy Grove
4cdd003cd4
Merge pull request #51 from nickolay/rust-2018
...
Rust 2018 and clippy fixes
2019-04-27 08:51:43 -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
76d2d46496
run cargo fmt
2019-04-22 18:06:00 -04:00
Justin Haug
f9fb4bedfb
Move wildcard test to generic parser
2019-04-22 17:52:15 -04: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
08bbce8992
Use assert_matches! instead of matching manually
...
To fix clippy warnings about assert!(true / false)
2019-04-21 04:46:19 +03:00
Nickolay Ponomarev
dee30aabe0
Fix the clippy assert!(false)
lint
...
https://rust-lang.github.io/rust-clippy/master/index.html#assertions_on_constants
While I don't feel it's valid, fixing it lets us act on the other, more
useful, lints.
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
8c7e1d1c54
Update sample output in README
2019-04-20 22:51:29 +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
Andy Grove
ef76baa7fd
(cargo-release) start next development iteration 0.3.1
2019-04-20 07:33:37 -06:00
Andy Grove
1aa4733890
bump version
2019-04-20 07:33:21 -06:00
Andy Grove
6ebd5dd819
Merge pull request #49 from nickolay/select-distinct
...
Support SELECT DISTINCT, and a few minor tweaks
2019-04-20 07:26:13 -06: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