Commit graph

73 commits

Author SHA1 Message Date
Nikhil Benesch
90bcf55a6a
Fix the precedence of NOT LIKE
NOT LIKE has the same precedence as the LIKE operator. The parser was
previously assigning it the precedence of the unary NOT operator. NOT
BETWEEN and NOT IN are treated similarly, as they are equivalent, from a
precedence perspective, to NOT LIKE.

The fix for this requires associating precedences with sequences of
tokens, rather than single tokens, so that "NOT LIKE" and "NOT <expr>"
can have different preferences. Perhaps surprisingly, this change is not
very invasive.

An alternative I considered involved adjusting the tokenizer to lex
NOT, NOT LIKE, NOT BETWEEN, and NOT IN as separate tokens. This broke
symmetry in strange ways, though, as NotLike, NotBetween, and NotIn
gained dedicated tokens, while LIKE, BETWEEN, and IN remained as
stringly identifiers.

Fixes #81.
2019-06-01 02:52:18 -04:00
Justin Haug
2d00ea7187
Add lateral derived support 2019-05-31 18:10:25 -04:00
Justin Haug
fe10fac0ad
Add FETCH and OFFSET support 2019-05-31 18:10:24 -04:00
Nikhil Benesch
202464a06a
Merge pull request #68 from ivanceras/master
Add LIMIT as RESERVED_FOR_TABLE_ALIAS
2019-05-31 18:08:26 -04:00
Nikhil Benesch
b2c93bd969
Enforce clippy and rustfmt in CI 2019-05-31 18:06:51 -04:00
Nickolay Ponomarev
d80f9f3a7a
Merge pull request #80 from benesch/between-expr
Support nested expressions in BETWEEN
2019-05-30 02:37:06 +03:00
Nickolay Ponomarev
646479e56c
Merge pull request #77 from benesch/count-distinct
Support COUNT(DISTINCT x) and similar
2019-05-30 02:35:49 +03:00
Nickolay Ponomarev
86a2fbd8e4
Merge pull request #76 from benesch/select-all
Support SELECT ALL
2019-05-30 02:35:18 +03:00
Nickolay Ponomarev
7a6a66bdc5
Merge pull request #75 from benesch/drop
Support DROP [TABLE|VIEW]
2019-05-30 02:33:33 +03:00
Jamie Brandon
72ced4bffe
Support COUNT(DISTINCT x) and similar 2019-05-28 16:59:05 -04:00
Nikhil Benesch
ba21ce9d37
Support nested expressions in BETWEEN
`BETWEEN <thing> AND <thing>` allows <thing> to be any expr that doesn't
contain boolean operators. (Allowing boolean operators would wreak
havoc, because of the repurposing of AND as both a boolean operation
and part of the syntax of BETWEEN.)
2019-05-28 16:42:11 -04:00
Nikhil Benesch
187376e657
Support DROP [TABLE|VIEW]
Co-authored-by: Jamie Brandon <jamie@scattered-thoughts.net>
2019-05-26 19:57:33 -04:00
Jamie Brandon
55fc8c5a57
Support SELECT ALL
Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
2019-05-26 18:57:04 -04:00
Nikhil Benesch
5652b4676c
Replace Option<Vec<T>> with Vec<T>
Vectors can already represent the absence of any arguments (i.e., by
being empty), so there is no need to wrap them in an Option.
2019-05-22 11:42:28 -04:00
Jamie Brandon
143846d333
Don't panic on weird infix garbage
Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
2019-05-21 11:59:45 -04:00
Jovansonlee Cesar
d263d285e2 Add LIMIT as RESERVED_FOR_TABLE_ALIAS, this closes Issue#67 2019-05-18 10:53:19 +08:00
Nickolay Ponomarev
eeae3af6a3 Change the default serialization of "not equals" operator to <>
`!=` is not standard, though widely supported - https://stackoverflow.com/a/723426/1026
2019-05-06 22:20:29 +03:00
Nickolay Ponomarev
cccf7f0d8e Parse an optional column list after a CTE 2019-05-06 22:20:29 +03:00
Nickolay Ponomarev
f859c9b80e Support COLLATE in expressions
Roughly the <character factor> production - https://jakewheat.github.io/sql-overview/sql-2011-foundation-grammar.html#character-factor

If an expression is followed by the keyword `COLLATE`, it must be
followed by the collation name, which is optionally schema-qualified
identifier.

The `COLLATE` keyword is not a regular binary operator in that it can't
be "nested": `foo COLLATE bar COLLATE baz` is not valid. If you prefer
to think of it as an operator, you might say it has the highest
precedence (judging from the spec), i.e. it binds to the smallest valid
expression to the left of it (so in `foo < bar COLLATE c`, the COLLATE
is applied first).
2019-05-06 22:20:29 +03:00
Nickolay Ponomarev
67cc880fd1 Add comments to the test files 2019-05-04 02:43:00 +03:00
Nickolay Ponomarev
304710d59a Add MSSQL dialect and fix up the postgres' identifier rules
The `@@version` test is MS' dialect of SQL, it seems, so test it with
its own dialect.

Update the rules for identifiers in Postresql dialect per documentation,
while we're at it. The current identifier rules in Postgresql dialect
were introduced in this commit - as a copy of generic rules, it seems:
810cd8e6cf (diff-2808df0fba0aed85f9d35c167bd6a5f1L138)
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
Renamed from tests/sqlparser_generic.rs (Browse further)