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:
AugustoFKL 2022-10-31 16:22:34 -03:00 committed by GitHub
parent f0646c8c1a
commit 1b3778e2d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 65 additions and 31 deletions

View file

@ -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]