mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-30 18:57:21 +00:00
feature!: added NUMERIC and DEC ANSI data types, and now the DECIMAL (#695)
type prints DECIMAL instead of NUMERIC. BREAKING CHANGE: enum DATA TYPE variants changed, changing any API that uses it.
This commit is contained in:
parent
f0646c8c1a
commit
1b3778e2d5
4 changed files with 65 additions and 31 deletions
|
@ -18,10 +18,8 @@
|
|||
//! sqlparser regardless of the chosen dialect (i.e. it doesn't conflict with
|
||||
//! dialect-specific parsing rules).
|
||||
|
||||
#[macro_use]
|
||||
mod test_utils;
|
||||
|
||||
use matches::assert_matches;
|
||||
|
||||
use sqlparser::ast::SelectItem::UnnamedExpr;
|
||||
use sqlparser::ast::*;
|
||||
use sqlparser::dialect::{
|
||||
|
@ -30,12 +28,14 @@ use sqlparser::dialect::{
|
|||
};
|
||||
use sqlparser::keywords::ALL_KEYWORDS;
|
||||
use sqlparser::parser::{Parser, ParserError};
|
||||
|
||||
use test_utils::{
|
||||
all_dialects, assert_eq_vec, expr_from_projection, join, number, only, table, table_alias,
|
||||
TestedDialects,
|
||||
};
|
||||
|
||||
#[macro_use]
|
||||
mod test_utils;
|
||||
|
||||
#[test]
|
||||
fn parse_insert_values() {
|
||||
let row = vec![
|
||||
|
@ -1628,15 +1628,9 @@ fn parse_cast() {
|
|||
|
||||
verified_stmt("SELECT CAST(id AS NUMERIC) FROM customer");
|
||||
|
||||
one_statement_parses_to(
|
||||
"SELECT CAST(id AS DEC) FROM customer",
|
||||
"SELECT CAST(id AS NUMERIC) FROM customer",
|
||||
);
|
||||
verified_stmt("SELECT CAST(id AS DEC) FROM customer");
|
||||
|
||||
one_statement_parses_to(
|
||||
"SELECT CAST(id AS DECIMAL) FROM customer",
|
||||
"SELECT CAST(id AS NUMERIC) FROM customer",
|
||||
);
|
||||
verified_stmt("SELECT CAST(id AS DECIMAL) FROM customer");
|
||||
|
||||
let sql = "SELECT CAST(id AS NVARCHAR(50)) FROM customer";
|
||||
let select = verified_only_select(sql);
|
||||
|
@ -1720,22 +1714,13 @@ fn parse_try_cast() {
|
|||
},
|
||||
expr_from_projection(only(&select.projection))
|
||||
);
|
||||
one_statement_parses_to(
|
||||
"SELECT TRY_CAST(id AS BIGINT) FROM customer",
|
||||
"SELECT TRY_CAST(id AS BIGINT) FROM customer",
|
||||
);
|
||||
verified_stmt("SELECT TRY_CAST(id AS BIGINT) FROM customer");
|
||||
|
||||
verified_stmt("SELECT TRY_CAST(id AS NUMERIC) FROM customer");
|
||||
|
||||
one_statement_parses_to(
|
||||
"SELECT TRY_CAST(id AS DEC) FROM customer",
|
||||
"SELECT TRY_CAST(id AS NUMERIC) FROM customer",
|
||||
);
|
||||
verified_stmt("SELECT TRY_CAST(id AS DEC) FROM customer");
|
||||
|
||||
one_statement_parses_to(
|
||||
"SELECT TRY_CAST(id AS DECIMAL) FROM customer",
|
||||
"SELECT TRY_CAST(id AS NUMERIC) FROM customer",
|
||||
);
|
||||
verified_stmt("SELECT TRY_CAST(id AS DECIMAL) FROM customer");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue