Commit graph

20 commits

Author SHA1 Message Date
Nikhil Benesch
cf655ad1a6
Remove "sql" prefix from module names
Since this crate only deals with SQL parsing, the modules are understood
to refer to SQL and don't need to restate that explicitly.
2019-06-24 12:56:26 -04:00
Nickolay Ponomarev
26fac099b1 Update Value docs 2019-06-12 21:04:23 +03:00
Andy Grove
b379480b7a
Merge pull request #79 from benesch/license
Standardize license headers
2019-06-10 19:39:12 -06:00
Nikhil Benesch
2798ddf5fd
Support interval literals 2019-06-09 12:37:57 -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
ed3ed26bb1
Support parsing dates, times, and timestamps as strings 2019-06-04 00:12:09 -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
eba3983268
Support hexadecimal string literals 2019-06-03 11:33:51 -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
Nickolay Ponomarev
d9edc2588b Change Value::Long() to u64, use u64 instead of usize
The tokenizer emits a separate Token for +/- signs, so the value of
Value::Long() (as well as of parse_literal_int()) may never be negative.

Also we have been using both u64 and usize to represent a parsed
unsigned number. Change to using u64 for consistency.
2019-06-02 13:58:14 +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
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
Justin Haug
80dccf6885 Add support for escaping single quote strings 2019-04-22 13:32:05 -04:00
Nickolay Ponomarev
35dd9342e2 Support national string literals (N'...')
Widely used in MS SQL and specified in ANSI.
2019-02-07 05:34:33 +03:00
Nickolay Ponomarev
078eb677a1 Remove Value::String
Its existence alongside SingleQuotedString simply doesn't make sense:
`'a string'` is a string literal, while `a string` is not a "value".

It's only used in postgresql-specific tab-separated-values parser to
store the string representation of a field's value. For that use-case
Option<String> looks like a more appropriate choice than Value.
2019-01-20 19:26:58 +03:00
Nickolay Ponomarev
56884dc700 Remove Value::DoubleQuotedString
...and parser support for the corresponding token, as "..." in SQL[*] is
not a literal string like we parse it - but a quoted identifier (which I
intend to implement later).

[*] in all the RBDMSes I know, except for sqlite which has complex rules
in the name of "compatibility": https://www.sqlite.org/lang_keywords.html
2019-01-20 19:26:58 +03:00
Andy Grove
e863bc041c cargo fmt, fix compiler warnings 2018-12-16 13:57:01 -07:00
Andy Grove
661ada0664 fix compiler warnings 2018-10-06 09:58:16 -06:00
Andy Grove
722ea7a91b ran cargo fmt 2018-10-06 09:39:26 -06:00
Jovansonlee Cesar
5abd9e7dec Modularized into separate files
Add ToString implementation on the components
2018-09-30 03:34:37 +08:00