Skip to content

Commit

Permalink
Merge pull request #20 from THCLab/feat/refs-serialziation
Browse files Browse the repository at this point in the history
fix: Serialize reference to refs
  • Loading branch information
mitfik authored Dec 5, 2023
2 parents a4f695d + dc92abe commit 408950a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion oca-ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ pub enum AttributeType {
DateTime,
#[serde(rename = "Array[DateTime]")]
ArrayDateTime,
#[serde(rename = "refs")]
Reference,
#[serde(rename = "Array[Reference]")]
ArrayReference,
Expand All @@ -85,7 +86,7 @@ impl FromStr for AttributeType {
"Array[Reference]" => Ok(AttributeType::ArrayReference),
_ => {
if let Some((attr_type, _)) = s.split_once(':') {
if attr_type == "Reference" {
if attr_type == "refs" {
Ok(AttributeType::Reference)
} else if attr_type == "Array[Reference" {
Ok(AttributeType::ArrayReference)
Expand Down
3 changes: 2 additions & 1 deletion oca/tests/build_from_ocafile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ ADD ATTRIBUTE x=Text
Ok(())
}

#[cfg(feature = "local-references")]
#[test]
fn build_with_references() -> Result<(), Vec<Error>> {
let db = InMemoryDataStorage::new();
Expand All @@ -89,7 +90,7 @@ ADD ATTRIBUTE B=refn:other

assert_eq!(
result.said.unwrap().to_string(),
"EPZNx7Vbl06cYdsAKbRVtgxUOoLcap61Go7ueau1RjEN"
"ELxZNFB5vW8_wDKLsAyAiX2AdsiNIHuw_1ZakI7LBbgd"
);
Ok(())
}
Expand Down

0 comments on commit 408950a

Please sign in to comment.