Commit graph

399 commits

Author SHA1 Message Date
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
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
Nikhil Benesch
eba3983268
Support hexadecimal string literals 2019-06-03 11:33:51 -04:00
Nikhil Benesch
057518b377
Merge pull request #88 from benesch/hash
Implement Hash on all AST nodes
2019-06-03 11:29:31 -04:00
Nikhil Benesch
7aff70772b
Merge pull request #90 from benesch/exists
Support EXISTS subqueries
2019-06-03 11:29:04 -04:00
Nikhil Benesch
14e07ebdda
Support arbitrary INSERT sources
INSERT takes arbitrary queries as sources, not just VALUES clauses. For
example, `INSERT INTO foo SELECT * FROM bar` is perfectly valid.
2019-06-03 11:27:21 -04:00
Nikhil Benesch
9420070a0d
Support VALUES clauses in FROM
VALUES clauses are not just valid in INSERT statements. They're also
valid (basically) anywhere table expressions are accepted, like in FROM
clauses.
2019-06-03 11:26:45 -04:00
Nikhil Benesch
975106b207
Support EXISTS subqueries
Fix #5.
2019-06-03 11:14:24 -04:00
Nikhil Benesch
c49352f394
Implement Hash on all AST nodes
It is convenient for downstream libraries to be able to stash bits of
ASTs into hash maps, e.g., for performing simple common subexpression
elimination.

The only downside to this change is that it requires that the f64 in the
Value enum be wrapped in an OrderedFloat, which provides the necessary
equality semantics to allow Hash to be drived. The reason f64 doesn't
implement Hash by default is because NaN is typically not equal to
itself, so it's not clear what it should hash to. That's less of a
concern in a SQL context, because every SQL database I've looked at
treats NaN as equal to itself, in violation of the IEEE standard, in
order to permit indexing and sorting of float columns.
2019-06-03 11:11:24 -04:00
Nikhil Benesch
a3aaa49a7e
Merge pull request #89 from benesch/sqlfunction-struct
Extract a SQLFunction struct
2019-06-03 11:09:27 -04:00
Nikhil Benesch
1ddef7aa71
Merge pull request #92 from benesch/decimal-dec
Parse DECIMAL and DEC aliases for NUMERIC type
2019-06-03 11:08:18 -04:00
Nikhil Benesch
85ba953ea1
Merge pull request #87 from nickolay/pr/join-refactor
Refactor parse_joins
2019-06-03 00:55:23 -04:00
Nikhil Benesch
1cef68e510
Support UPDATE statements
Fix #10.
2019-06-03 00:21:23 -04:00
Nikhil Benesch
b3a2a6be48
Support CREATE TABLE with no columns
This is weird, but supported by PostgreSQL.
2019-06-02 23:50:16 -04:00
Nikhil Benesch
054a59df12
Extract a SQLFunction struct
This variant is getting rather large, and it's useful downstream to be
able to pass around SQLFunction nodes without reinventing the wheel.
2019-06-02 23:00:28 -04:00