Max Countryman
6cdd4a146d
Support general "typed string" literals ( #187 )
...
Fixes #168 by enabling `DATE` and other keywords to be used as
identifiers when not followed by a string literal.
A "typed string" is our term for generalized version of `DATE '...'`/`TIME '...'`/
`TIMESTAMP '...'` literals, represented as `TypedString { data_type, value }`
in the AST.
Unlike DATE/TIME/TIMESTAMP literals, this is a non-standard extension
supported by PostgreSQL at least.
This is a port of MaterializeInc/materialize#3146
Co-authored-by: Nikhil Benesch <nikhil.benesch@gmail.com>
Co-authored-by: Nickolay Ponomarev <asqueella@gmail.com>
2020-06-12 00:04:43 +03:00
Daniël Heres
34548e890b
Change Word::keyword to a enum ( #193 )
...
This improves performance and paves the way to future API enhancements as discussed in the PR https://github.com/andygrove/sqlparser-rs/pull/193
2020-06-11 22:00:35 +03:00
Nickolay Ponomarev
0fe3a8ec39
Use Token::EOF instead of Option<Token> ( #195 )
...
This simplifies codes slightly, removing the need deal with the EOF case explicitly.
The clone kludge in `_ => self.expected("date/time field",
Token::Word(w.clone())))` will become unnecessary once we stop using
a separate match for the keywords, as suggested in
https://github.com/andygrove/sqlparser-rs/pull/193#issuecomment-641607194
2020-06-10 14:05:17 +03:00
Taehoon Moon
2f1015339a
Add serde support to AST structs and enums ( #196 )
...
Apply serde to AST structs and enums to be serializable/deserializable.
serde support is optional, can be activated by feature named "serde".
2020-06-10 12:53:52 +03:00
Nickolay Ponomarev
d9a7491d9a
Various follow-ups to recent pushes
...
- Update CHANGELOG
- Update `.gitignore` for the build directory of the benchmark crate
- Remove src/lib from the recently added benchmark crate per
https://github.com/andygrove/sqlparser-rs/pull/190#pullrequestreview-425835379
2020-06-10 09:40:42 +03:00
Max Countryman
846c52f450
Allow omitting units after INTERVAL ( #184 )
...
Alter INTERVAL to support postgres syntax
This patch updates our INTERVAL implementation such that the Postgres
and Redshfit variation of the syntax is supported: namely that 'leading
field' is optional.
Fixes #177 .
2020-06-10 09:32:13 +03:00
Daniël Heres
d842f495db
Add line and column number to TokenizerError ( #194 )
...
Addresses https://github.com/andygrove/sqlparser-rs/issues/179 for tokenize errors
2020-06-10 09:15:44 +03:00
Nickolay Ponomarev
10b0b7f884
Update CHANGELOG ( #192 )
...
Also remove a comment with a trailing space, which rustfmt doesn't like
2020-06-07 20:43:44 +03:00
Daniël Heres
a42121de52
Use binary search to speed up matching keywords ( #191 )
2020-06-07 20:25:10 +03:00
Max Countryman
af54eb02b2
Rework github actions, add code coverage ( #186 )
...
This reworks our GitHub Actions workflow to include code coverage via
tarpaulin.
Fixes #164 .
2020-06-07 20:15:31 +03:00
Daniël Heres
6e6fae73a0
Add benchmarks using cargo bench / criterion ( #190 )
2020-06-07 16:46:55 +03:00
Daniël Heres
d32df527e6
Accept &str in Parse::parse_sql
( #182 )
...
It is more generic to accept a `&str` than a `String` in an API,
and avoids having to convert a string to a `String` when not
needed, avoiding a copy.
2020-06-03 23:31:41 +03:00
Daniël Heres
b4699bd4a7
Support bitwise and, or, xor ( #181 )
...
Operator precedence is coming from:
https://cloud.google.com/bigquery/docs/reference/standard-sql/operators
2020-06-03 19:02:05 +03:00
Daniël Heres
00dc490f72
Support the string concat operator ( #178 )
...
The selected precedence is based on BigQuery documentation, where it is equal to `*` and `/`:
https://cloud.google.com/bigquery/docs/reference/standard-sql/operators
2020-06-02 21:24:30 +03:00
Max Countryman
5f3c1bda01
Provide LISTAGG implementation ( #174 )
...
This patch provides an initial implemenation of LISTAGG[1]. Notably this
implemenation deviates from ANSI SQL by allowing both WITHIN GROUP and
the delimiter to be optional. We do so because Redshift SQL works this
way and this approach is ultimately more flexible.
Fixes #169 .
[1] https://modern-sql.com/feature/listagg
2020-05-30 18:50:17 +03:00
QP Hou
418b9631ce
add nulls first/last support to order by expression ( #176 )
...
Following `<sort specification list>` from the standard https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#_10_10_sort_specification_list
2020-05-30 17:05:15 +03:00
Nickolay Ponomarev
c918ff042d
Merge pull request #173 from alex-dukhno/create-schema
...
Support `CREATE SCHEMA schema_name` and `DROP SCHEMA schema_name`.
Both ANSI SQL and Posgres define a number of options for the CREATE SCHEMA statement.
They also support including other CREATE statements as part of the schema definition,
rather than separate statements. This PR supports neither.
2020-05-28 21:05:34 +03:00
Alex Dukhno
91f769e460
added create and drop schema
2020-05-28 19:50:16 +03:00
Nickolay Ponomarev
b28dd82838
Merge pull request #172 from nickolay/pr/readme
...
documentation updates
2020-05-27 19:49:50 +03:00
Nickolay Ponomarev
1cf9e5ecef
Update README: we support bits and pieces from other dialects too
2020-05-27 19:45:18 +03:00
Nickolay Ponomarev
a2f4996bdd
Update README to point to SQL:2016, instead of 2011
...
This was discussed in #125 , but we forgot to update the README at the time.
2020-05-27 19:45:18 +03:00
Nickolay Ponomarev
8d5eaf95b3
Update CHANGELOG
2020-05-27 19:44:59 +03:00
Christoph Müller
98f97d09db
Add support for "on delete cascade" column option ( #170 )
...
Specifically, `FOREIGN KEY REFERENCES <foreign_table> (<referred_columns>)`
can now be followed by `ON DELETE <referential_action>` and/or by
`ON UPDATE <referential_action>`.
2020-05-27 18:24:23 +03:00
Nickolay Ponomarev
789fcc8521
Merge pull request #167 from mashuai/add_index_support
...
Adds support for the most common forms of CREATE INDEX, and for DROP INDEX:
CREATE [ UNIQUE ] INDEX [ IF NOT EXISTS ]
<index_name>
ON <table_name>
( col_name [, ...] )
DROP INDEX <index_name>
2020-05-27 05:13:06 +03:00
Nickolay Ponomarev
320d2f2d05
Update CHANGELOG.md and a fix last-minute review nit
2020-05-27 05:04:22 +03:00
mashuai
5aacc5ebcd
add create index and drop index support
2020-05-27 09:27:57 +08:00
Nickolay Ponomarev
2644bc4ac7
Merge pull request #171 from nickolay/master
...
Fix GitHub CI failures.
2020-05-26 21:47:25 +03:00
Nickolay Ponomarev
8406a938d5
Port the changes made to travis configuration in #159 to GitHub workflows
...
This should fix the build failures due to unavailable components, e.g.
error: component 'rustfmt' for target 'x86_64-unknown-linux-gnu' is unavailable for download for channel nightly
Sometimes not all components are available in any given nightly.
2020-05-26 21:35:12 +03:00
Nickolay Ponomarev
f614481133
Merge pull request #165 from nickolay/pr/unterminated-string-literal
...
Report an error on unterminated string literals (and more)
2020-05-26 06:42:35 +03:00
Nickolay Ponomarev
7d60bfd866
Update CHANGELOG.md
2020-05-10 21:50:06 +03:00
Nickolay Ponomarev
327e6cd9f1
Report an error for unterminated string literals
...
...updated the TODOs regarding single-quoted literals parsing while at it.
2020-05-10 21:21:01 +03:00
Nickolay Ponomarev
40853fe412
Fix a recently implemented clippy lint
...
https://rust-lang.github.io/rust-clippy/master/index.html#single_component_path_imports
"Import with single component use path such as `use cratename;`
is not necessary, and thus should be removed."
2020-05-10 21:16:25 +03:00
Alex Dukhno
5ad578e3e5
Implement CREATE TABLE IF NOT EXISTS ( #163 )
...
A non-standard feature supported at least by Postgres
https://www.postgresql.org/docs/12/sql-createtable.html
2020-04-21 16:28:02 +03:00
Nickolay Ponomarev
06865113d7
Update comments (follow-up to PR #158 )
2020-04-20 05:43:57 +03:00
Nickolay Ponomarev
af852e78f6
Merge pull request #158 from mjibson/offset-rows
...
Add support for OFFSET without the ROWS keyword (a MySQL quirk, documented at https://dev.mysql.com/doc/refman/8.0/en/select.html )
Teach the parser to remember which variant it saw (ROWS/ROW/none).
2020-04-20 05:38:04 +03:00
Nickolay Ponomarev
5fe9060d4e
Merge pull request #162 from alex-dukhno/derive-defaul-for-generic-dialect
...
derive default for GenericDialect
2020-04-20 05:13:12 +03:00
Matt Jibson
c0b0b5924d
Add support for OFFSET with the ROWS keyword
...
MySQL doesn't support the ROWS part of OFFSET. Teach the parser to
remember which variant it saw, including just ROW.
2020-04-19 20:06:08 -06:00
Nickolay Ponomarev
05a29212ff
Update comments (follow-up to PR #155 )
...
https://github.com/andygrove/sqlparser-rs/pull/155
2020-04-20 04:58:24 +03:00
Nickolay Ponomarev
33303b244f
Merge pull request #155 from eyalleshem/master
...
Accept non-standard `Select * from (a)` queries, where the table name is inside parentheses.
2020-04-20 04:57:12 +03:00
Nickolay Ponomarev
b9f1ff685a
Merge pull request #159 to fix Travis CI
2020-04-20 03:02:54 +03:00
Alex Dukhno
baacc956ea
derive default for GenericDialect
2020-04-19 13:07:00 +03:00
Nickolay Ponomarev
dcc624c561
Make CI handle missing rustfmt in the nightly
2020-04-14 19:48:15 +03:00
Nickolay Ponomarev
4ce0eb11ae
Fix a new clippy lint (.nth(0)
) to unbreak CI
...
"iter.next() is equivalent to iter.nth(0), as they both consume the
next element, but is more readable."
https://rust-lang.github.io/rust-clippy/master/index.html#iter_nth_zero
2020-04-14 17:09:48 +03:00
Eyal Leshem
3255fd3ea8
Add support to to table_name inside parenthesis
2020-04-12 20:31:09 +03:00
Alex Kyllo
172ba42001
Add support for MSSQL's SELECT TOP N syntax ( #150 )
...
Add support for MSSQL SELECT TOP (N) [PERCENT] [WITH TIES] syntax.
2020-01-12 23:20:48 -05:00
Nikhil Benesch
4cdd6e2f84
Merge pull request #143 from apparebit/quote-id-quote
...
Support quoted identifiers in AST as well
2019-10-20 00:20:44 -04:00
Robert Grimm
b1cbc55128
Turn type Ident into struct Ident
...
The Ident type was previously an alias for a String. Turn it into a full
fledged struct, so that the parser can preserve the distinction between
identifier value and quote style already made by the tokenizer's Word
structure.
2019-10-20 00:16:41 -04:00
Andy Grove
9b2287f14c
Merge pull request #142 from andygrove/github-action
...
Add Github Action
2019-10-17 20:50:46 -06:00
Andy Grove
a2613f9dd1
format
2019-10-17 20:41:49 -06:00
Andy Grove
0687d3aca8
stable rust
2019-10-17 20:38:22 -06:00