Make numeric literal underscore test dialect agnostic (#1685)

This commit is contained in:
Ifeanyi Ubah 2025-01-31 00:05:36 +01:00 committed by GitHub
parent 9c384a9194
commit 94b2ff7191
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 18 additions and 15 deletions

View file

@ -1649,21 +1649,6 @@ fn parse_table_sample() {
clickhouse().verified_stmt("SELECT * FROM tbl SAMPLE 1 / 10 OFFSET 1 / 2");
}
#[test]
fn parse_numbers_with_underscore() {
let canonical = if cfg!(feature = "bigdecimal") {
"SELECT 10000"
} else {
"SELECT 10_000"
};
let select = clickhouse().verified_only_select_with_canonical("SELECT 10_000", canonical);
assert_eq!(
select.projection,
vec![SelectItem::UnnamedExpr(Expr::Value(number("10_000")))]
)
}
fn clickhouse() -> TestedDialects {
TestedDialects::new(vec![Box::new(ClickHouseDialect {})])
}

View file

@ -55,6 +55,24 @@ use sqlparser::ast::Expr::{Identifier, UnaryOp};
use sqlparser::ast::Value::Number;
use sqlparser::test_utils::all_dialects_except;
#[test]
fn parse_numeric_literal_underscore() {
let dialects = all_dialects_where(|d| d.supports_numeric_literal_underscores());
let canonical = if cfg!(feature = "bigdecimal") {
"SELECT 10000"
} else {
"SELECT 10_000"
};
let select = dialects.verified_only_select_with_canonical("SELECT 10_000", canonical);
assert_eq!(
select.projection,
vec![UnnamedExpr(Expr::Value(number("10_000")))]
);
}
#[test]
fn parse_insert_values() {
let row = vec![