Skip to content

Commit

Permalink
wip: pass the decimal context to its constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
ashigeru committed Jul 4, 2024
1 parent 87d8dc9 commit 583489e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/mizugaki/analyzer/details/analyze_literal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,9 @@ class engine {
// FIXME: other decimal context
};

::decimal::Decimal v { *value.unsigned_value() };
::decimal::Decimal v { *value.unsigned_value(), context };
if (value.sign() == ast::literal::sign::minus) {
auto v2 = v.minus(context);
v = std::move(v2);
v = v.minus(context);
}
if (!v.iszero() && !v.isnormal(context)) {
context_.report(sql_analyzer_code::unsupported_decimal_value,
Expand All @@ -213,6 +212,7 @@ class engine {
<< string_builder::to_string,
value.region());
}
// SQL does not support number with positive exponent
if (v.exponent() > 0) {
context_.report(sql_analyzer_code::unsupported_decimal_value,
string_builder {}
Expand Down
2 changes: 1 addition & 1 deletion test/mizugaki/analyzer/details/analyze_literal_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ TEST_F(analyze_literal_test, exact_numeric_decimal38_boundary_over) {
options_.prefer_small_decimal_literals() = false;
std::string p39;
p39.resize(39, '0');
p39[0] = '0'; // 10{38}
p39[0] = '1'; // 10{38}
invalid(sql_analyzer_code::unsupported_decimal_value, ast::literal::numeric {
ast::literal::kind::exact_numeric,
{},
Expand Down

0 comments on commit 583489e

Please sign in to comment.