Skip to content

feat(types): Add into_inner and into_inner_as methods for Value type #511

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

izumkineno
Copy link

I can not find methods to get my data from Value, so I write this, but may be need test

    let rows = stmt
        .query_map([], |row| {
            use duckvfslink::duckdb::types::Value;

            let id: String = row.get(0).unwrap();
            let pid: String = row.get(1).unwrap();
            let fid: String = row.get(2).unwrap();
            let ps: Value = row.get(3).unwrap();
            let is_active: bool = row.get(4).unwrap();
            let is_dir: bool = row.get(5).unwrap();

            let t = ps.into_inner_as::<Vec<Value>>().unwrap();
            let ps: Vec<String> = t
                .into_iter()
                .map(|v| v.into_inner_as::<String>())
                .filter_map(|v| v)
                .collect::<Vec<String>>();

            Ok(TreeViewNode {
                id,
                pid,
                fid,
                ps,
                is_active,
                is_dir,
            })
        })
        .unwrap()
        .filter_map(|r| r.ok())
        .collect::<Vec<_>>();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant