Skip to content

Commit f300f28

Browse files
Add 'dec' suffix to notation of 'Decimal' type (#736)
## Usage and product changes Add 'dec' suffix to notation of 'Decimal' type ## Implementation Add 'dec' suffix to notation of 'Decimal' type. Covers: * converting to JSON * In BDD * In tests.
1 parent b0ad8a5 commit f300f28

File tree

8 files changed

+14
-12
lines changed

8 files changed

+14
-12
lines changed

dependencies/typedb/artifacts.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def typedb_artifact():
2525
artifact_name = "typedb-all-{platform}-{version}.{ext}",
2626
tag_source = deployment["artifact"]["release"]["download"],
2727
commit_source = deployment["artifact"]["snapshot"]["download"],
28-
commit = "42bd82750e77af4e365c7ea697d24c43740a2dc1"
28+
commit = "b80b2a70a48bf6808712502509ab0d5526e0218a"
2929
)
3030

3131
#def typedb_cloud_artifact():

dependencies/typedb/repositories.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ def typedb_behaviour():
3535
git_repository(
3636
name = "typedb_behaviour",
3737
remote = "https://github.com/typedb/typedb-behaviour",
38-
commit = "7a0693ef7142480fb29acc42248f2166d0903d09", # sync-marker: do not remove this comment, this is used for sync-dependencies by @typedb_behaviour
38+
commit = "bc3a83004cc390a62b466aee623c851a0251d48c", # sync-marker: do not remove this comment, this is used for sync-dependencies by @typedb_behaviour
3939
)

java/test/behaviour/query/QuerySteps.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ public Object parseExpectedValue(String value, Optional<Parameters.ValueType> va
717717
case DOUBLE:
718718
return Double.parseDouble(value);
719719
case DECIMAL:
720-
return new BigDecimal(value).setScale(DECIMAL_SCALE, RoundingMode.UNNECESSARY);
720+
return new BigDecimal(value.replace("dec", "")).setScale(DECIMAL_SCALE, RoundingMode.UNNECESSARY);
721721
case STRING:
722722
return value.substring(1, value.length() - 1).replace("\\\"", "\"");
723723
case DATE:

java/test/integration/core/ValueTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ public void attributes() {
9898
Map.entry("name", "\"John\""),
9999
Map.entry("is-new", "true"),
100100
Map.entry("success", "66.6"),
101-
Map.entry("balance", "1234567890.0001234567890"),
101+
Map.entry("balance", "1234567890.0001234567890dec"),
102102
Map.entry("birth-date", "2024-09-20"),
103103
Map.entry("birth-time", "1999-02-26T12:15:05"),
104104
Map.entry("current-time", "2024-09-20T16:40:05 Europe/London"),
@@ -175,7 +175,7 @@ public void attributes() {
175175
checked.incrementAndGet();
176176
} else if (value.isDecimal()) {
177177
BigDecimal valueAsDecimal = value.getDecimal();
178-
assertEquals(new BigDecimal(attributeValues.get(attributeName)).setScale(valueAsDecimal.scale(), RoundingMode.UNNECESSARY), valueAsDecimal);
178+
assertEquals(new BigDecimal(attributeValues.get(attributeName).replace("dec", "")).setScale(valueAsDecimal.scale(), RoundingMode.UNNECESSARY), valueAsDecimal);
179179
checked.incrementAndGet();
180180
} else if (value.isDate()) {
181181
assertEquals(LocalDate.parse(attributeValues.get(attributeName)), value.getDate());

python/tests/behaviour/query/query_steps.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def parse_expected_value(value: str, value_type: Optional[ValueType]):
598598
elif value_type == ValueType.DOUBLE:
599599
return float(value)
600600
elif value_type == ValueType.DECIMAL:
601-
return Decimal(value)
601+
return Decimal(value.rstrip("dec"))
602602
elif value_type == ValueType.STRING:
603603
return value[1:-1].replace('\\"', '"')
604604
elif value_type == ValueType.DATE:

python/tests/integration/core/test_values.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_values(self):
5959
"name": "\"John\"",
6060
"is-new": "true",
6161
"success": "66.6",
62-
"balance": "1234567890.0001234567890",
62+
"balance": "1234567890.0001234567890dec",
6363
"birth-date": "2024-09-20",
6464
"birth-time": "1999-02-26T12:15:05",
6565
"current-time": "2024-09-20T16:40:05 Europe/Belfast",
@@ -134,7 +134,7 @@ def test_values(self):
134134
assert_that(value, is_(float(expected)))
135135
checked += 1
136136
elif attribute.is_decimal():
137-
assert_that(value, is_(Decimal(expected)))
137+
assert_that(value, is_(Decimal(expected.rstrip("dec"))))
138138
checked += 1
139139
elif attribute.is_date():
140140
date_format = "%Y-%m-%d"

rust/src/concept/value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ impl fmt::Debug for Decimal {
356356
}
357357

358358
let fractional_width = Self::FRACTIONAL_PART_DENOMINATOR_LOG10 - tail_0s;
359-
write!(f, "{}.{:0width$}", self.integer_part(), fractional, width = fractional_width as usize)?;
359+
write!(f, "{}.{:0width$}dec", self.integer_part(), fractional, width = fractional_width as usize)?;
360360
}
361361
Ok(())
362362
}

rust/tests/behaviour/steps/params.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,13 @@ impl Value {
100100
TypeDBValueType::Integer => TypeDBValue::Integer(self.raw_value.parse().unwrap()),
101101
TypeDBValueType::Double => TypeDBValue::Double(self.raw_value.parse().unwrap()),
102102
TypeDBValueType::Decimal => {
103-
let (integer, fractional) = if let Some(split) = self.raw_value.split_once(".") {
104-
split
103+
let stripped = if self.raw_value.ends_with("dec") {
104+
self.raw_value.trim_end_matches("dec")
105105
} else {
106-
(self.raw_value.as_str(), "0")
106+
self.raw_value.as_str()
107107
};
108+
let (integer, fractional) =
109+
if let Some(split) = stripped.split_once(".") { split } else { (stripped, "0") };
108110

109111
let integer_parsed: i64 = integer.trim().parse().unwrap();
110112
let integer_parsed_abs = integer_parsed.abs();

0 commit comments

Comments
 (0)