Skip to content

It seems Value::Union never used, please mark it as deprecated #12

@safinaskar

Description

@safinaskar

Hi. I'm unable to understand why we have Value::Union. I attempted to run this code:

use anyhow::Error;
use avrow::{Schema, Writer};
use std::str::FromStr;

fn main() -> Result<(), Error> {
    let schema = Schema::from_str(r##"{
        "type": "record",
        "name": "LongList",
        "aliases": ["LinkedLongs"],
        "fields" : [
          {"name": "value", "type": "long"},
          {"name": "next", "type": ["null", "LongList"]}
        ]
      }"##)?;
    let mut writer = Writer::new(&schema, std::io::stdout())?;
    let mut r = avrow::Record::new("LongList");
    r.insert("value", 2i64);
    r.insert("next", avrow::Value::Union(Box::new(avrow::Value::Null)));
    let res = writer.write(avrow::Value::Record(r))?;
    Ok(())
}

...and I got error Error: Value schema not found in union.
Then I tried this code (note line "XXX"):

use anyhow::Error;
use avrow::{Schema, Writer};
use std::str::FromStr;

fn main() -> Result<(), Error> {
    let schema = Schema::from_str(r##"{
        "type": "record",
        "name": "LongList",
        "aliases": ["LinkedLongs"],
        "fields" : [
          {"name": "value", "type": "long"},
          {"name": "next", "type": ["null", "LongList"]}
        ]
      }"##)?;
    let mut writer = Writer::new(&schema, std::io::stdout())?;
    let mut r = avrow::Record::new("LongList");
    r.insert("value", 2i64);
    r.insert("next", avrow::Value::Null); // XXX
    let res = writer.write(avrow::Value::Record(r))?;
    Ok(())
}

...and this time I got no error.

So, it seems from my experiments, that Value::Union is not used at all in avrow. Am I right?

I grepped avrow source code and now I even more sure that Value::Union is not used. All code samples I found was trivial, Value::Union is never constructed.

So, please, mark it as deprecated to make docs more clear

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions