Skip to content
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

Implementing the list, struct, map types fully #394

Open
CGenie opened this issue Nov 8, 2024 · 1 comment
Open

Implementing the list, struct, map types fully #394

CGenie opened this issue Nov 8, 2024 · 1 comment

Comments

@CGenie
Copy link

CGenie commented Nov 8, 2024

Hello,

I wanted to use duckdb-rs to insert a list of items. However, it turns out that this isn't implemented in duckdb-rs. See:

Value::List(vec_of_x) => Type::List(Value::data_type(x))

I'm not that advanced in rust. Maybe macros can help here? Anyways, the lack of such collection types in duckdb-rs is a big drawback for me.

@CGenie
Copy link
Author

CGenie commented Nov 8, 2024

BTW, I'm able to hack this with the following:

CREATE TABLE x (model STRUCT(mx DOUBLE, my DOUBLE, mz DOUBLE))

and then calling:

conn.execute("INSERT INTO x (model) values(?)", params![serde_json::json!(model_struct).to_string()])

i.e. I pass a Value::Text as a serialized JSON string, and duckdb is able to reimplement that transparently as a struct/list etc.

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

No branches or pull requests

1 participant