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
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
Nikhil Benesch
4c2722280d
Merge pull request #98 from benesch/col-names
...
Support column names in more places
2019-06-04 00:00:07 -04:00
Nikhil Benesch
9abcac350e
Support aliasing columns
...
A table alias can specify new names for the columns within the aliased
table, in addition to a new name for the table itself.
2019-06-03 23:51:23 -04:00
Nikhil Benesch
73ed685879
Support views with explicit column names
...
A `CREATE VIEW` statement may provide names for its columns that
override the names of the columns derived from the view's query.
2019-06-03 23:50:23 -04:00
Nikhil Benesch
fdbf64c64d
Merge pull request #94 from benesch/empty-create-table
...
Support CREATE TABLE with no columns
2019-06-03 23:44:18 -04:00
Nikhil Benesch
d484756182
Support EXTRACT function-like operator
...
The EXTRACT function, for extracting components of a date from a
timestamp, has special syntax: `EXTRACT(<field> FROM <timestamp>)`.
2019-06-03 23:37:39 -04:00
Nikhil Benesch
2f4cd8f6c8
Merge pull request #102 from benesch/ci-speedup
...
Speed up CI
2019-06-03 23:34:39 -04:00
Nikhil Benesch
a594375966
Merge pull request #97 from benesch/update
...
Support UPDATE statements
2019-06-03 23:32:23 -04:00
Nikhil Benesch
610d6f8304
Improve CI caching
...
We weren't making very effective use of the cache before, leading to
10m+ builds, as `cargo install --force` always busts the cache.
2019-06-03 17:46:20 -04:00
Nikhil Benesch
e753bd4f90
Install kcov via APT
...
This prevents cargo coveralls from downloading it and compiling it on
the fly.
2019-06-03 17:36:35 -04:00
Nikhil Benesch
b7125c979a
Upgrade CI to Xenial
...
This isn't required by anything, but newer distributions tend to boot
faster in Travis.
2019-06-03 17:33:44 -04:00
Nikhil Benesch
6fceba8aa1
Merge pull request #74 from benesch/with-options
...
Support arbitrary WITH options for CREATE [TABLE|VIEW]
2019-06-03 13:57:38 -04:00
Nikhil Benesch
69f0082db6
Support arbitrary WITH options for CREATE [TABLE|VIEW]
...
Both Postgres and MSSQL accept this syntax, though the particular
options they accept differ.
2019-06-03 13:32:13 -04:00
Nikhil Benesch
1931c76eb8
Merge pull request #101 from benesch/merge-skew
...
Fix merge skew by implementing Hash for SQLValues
2019-06-03 12:28:49 -04:00
Nikhil Benesch
fa3cf732d5
Fix merge skew by implementing Hash for SQLValues
2019-06-03 12:08:06 -04:00
Nikhil Benesch
b12fb34f3d
Merge pull request #95 from benesch/hex-literals
...
Support hexadecimal string literals
2019-06-03 11:49:25 -04:00
Nikhil Benesch
b8ba188191
Merge pull request #91 from benesch/from-values
...
Improve VALUES-related syntax parsing
2019-06-03 11:44:52 -04:00