Skip to content

Commit d31b302

Browse files
committed
test: merge negative scale tests
1 parent 19d163d commit d31b302

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

src/parser/mod.rs

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -11213,7 +11213,7 @@ impl<'a> Parser<'a> {
1121311213
if self.consume_token(&Token::LParen) {
1121411214
let precision = self.parse_literal_uint()?;
1121511215
let scale = if self.consume_token(&Token::Comma) {
11216-
Some(self.parse_scale_value()?)
11216+
Some(self.parse_signed_integer()?)
1121711217
} else {
1121811218
None
1121911219
};
@@ -17299,8 +17299,11 @@ mod tests {
1729917299
#[test]
1730017300
fn test_ansii_exact_numeric_types() {
1730117301
// Exact numeric types: <https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#exact-numeric-type>
17302-
let dialect =
17303-
TestedDialects::new(vec![Box::new(GenericDialect {}), Box::new(AnsiDialect {})]);
17302+
let dialect = TestedDialects::new(vec![
17303+
Box::new(GenericDialect {}),
17304+
Box::new(AnsiDialect {}),
17305+
Box::new(PostgreSqlDialect {}),
17306+
]);
1730417307

1730517308
test_parse_data_type!(dialect, "NUMERIC", DataType::Numeric(ExactNumberInfo::None));
1730617309

@@ -17363,53 +17366,33 @@ mod tests {
1736317366
DataType::Dec(ExactNumberInfo::PrecisionAndScale(5, -1000))
1736417367
);
1736517368

17366-
// Test positive scale with explicit plus sign
17367-
dialect.run_parser_method("NUMERIC(10,+5)", |parser| {
17368-
let data_type = parser.parse_data_type().unwrap();
17369-
assert_eq!(
17370-
DataType::Numeric(ExactNumberInfo::PrecisionAndScale(10, 5)),
17371-
data_type
17372-
);
17373-
// Note: Explicit '+' sign is not preserved in output, which is correct
17374-
assert_eq!("NUMERIC(10,5)", data_type.to_string());
17375-
});
17376-
}
17377-
17378-
#[test]
17379-
fn test_numeric_negative_scale() {
17380-
let dialect = TestedDialects::new(vec![
17381-
Box::new(PostgreSqlDialect {}),
17382-
Box::new(GenericDialect {}),
17383-
]);
17384-
17385-
// Test NUMERIC with negative scale
17369+
// Additional negative scale test cases
1738617370
test_parse_data_type!(
1738717371
dialect,
1738817372
"NUMERIC(10,-5)",
1738917373
DataType::Numeric(ExactNumberInfo::PrecisionAndScale(10, -5))
1739017374
);
1739117375

17392-
// Test DECIMAL with negative scale
1739317376
test_parse_data_type!(
1739417377
dialect,
1739517378
"DECIMAL(20,-10)",
1739617379
DataType::Decimal(ExactNumberInfo::PrecisionAndScale(20, -10))
1739717380
);
1739817381

17399-
// Test DEC with negative scale
1740017382
test_parse_data_type!(
1740117383
dialect,
1740217384
"DEC(5,-2)",
1740317385
DataType::Dec(ExactNumberInfo::PrecisionAndScale(5, -2))
1740417386
);
1740517387

17406-
// Test with explicit positive scale (note: +5 parses as 5, so display shows NUMERIC(10,5))
17388+
// Test positive scale with explicit plus sign
1740717389
dialect.run_parser_method("NUMERIC(10,+5)", |parser| {
1740817390
let data_type = parser.parse_data_type().unwrap();
1740917391
assert_eq!(
1741017392
DataType::Numeric(ExactNumberInfo::PrecisionAndScale(10, 5)),
1741117393
data_type
1741217394
);
17395+
// Note: Explicit '+' sign is not preserved in output, which is correct
1741317396
assert_eq!("NUMERIC(10,5)", data_type.to_string());
1741417397
});
1741517398
}

0 commit comments

Comments
 (0)