Skip to content

Commit

Permalink
change default id base to
Browse files Browse the repository at this point in the history
  • Loading branch information
andicuko committed Feb 23, 2024
1 parent 431cdfb commit 13b47a5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.6.1] - 2024-02-23
### Added
- Change default Prototype Id base to string when converting DataType::Id

## [0.6.0] - 2023-12-19
### Added
- Updated Qrlew version
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
authors = ["Nicolas Grislain <ng@sarus.tech>"]
name = "qrlew-sarus"
version = "0.6.0"
version = "0.6.1"
edition = "2021"
description = "Qrlew - Sarus interfaces"
documentation = "https://docs.rs/qrlew-sarus"
Expand Down
24 changes: 23 additions & 1 deletion src/data_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -868,9 +868,10 @@ impl <'a> TryFrom<&'a DataType> for type_::Type {
DataType::Id(id) => {
let mut id_type = type_::type_::Id::new();
id_type.set_unique(id.unique());
id_type.set_base(type_::type_::id::Base::STRING);

proto_type.set_name("Id".to_string());
proto_type.set_id(type_::type_::Id::new());
proto_type.set_id(id_type);
}
DataType::Function(_function) => {
return Err(Error::Other(
Expand Down Expand Up @@ -2024,9 +2025,30 @@ mod tests {
let sarus_type = DataType::from(&proto_data_type);
assert!(sarus_type == DataType::id());
let new_proto_data_type: type_::Type = (&sarus_type).try_into()?;
assert!(new_proto_data_type.id().base() == type_::type_::id::Base::STRING);
assert!(proto_data_type.id().unique() == new_proto_data_type.id().unique());

let type_str: &str = r#"
{
"@type": "sarus_data_spec/sarus_data_spec.Type",
"id": {
"base": "INT64",
"unique": true
},
"name": "Id",
"properties": {}
}
"#;
let proto_data_type: type_::Type = parse_from_str(type_str).unwrap();
let sarus_type = DataType::from(&proto_data_type);
assert!(sarus_type == DataType::id());
let new_proto_data_type: type_::Type = (&sarus_type).try_into()?;
assert!(new_proto_data_type.id().base() == type_::type_::id::Base::STRING);
assert!(proto_data_type.id().unique() == new_proto_data_type.id().unique());

Ok(())


}

#[test]
Expand Down

0 comments on commit 13b47a5

Please sign in to comment.