-
-
Notifications
You must be signed in to change notification settings - Fork 192
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
Implemented 'Array' type for Postgres. #205
Conversation
This introduces "Array" as a new Value variant. It can be derived from all Vec<T> types, where T is a valid Value, except for u8, which is already handled by Bytes.
Hmm, actually, this will not work because we cannot provide bindings to Sqlx. Sqlx expects |
Hey @kev0960, thanks for the contributions! I assumed you want to support |
Yes I do :) |
I don't like the idea but we can probably workaround by defining bunch of definitions like
and treat them individually. I really cant think of the "clean" way to convert the generic Any ideas are welcomed :) |
Let me think loll :P |
|
||
#[cfg(feature = "with-array")] | ||
#[cfg_attr(docsrs, doc(cfg(feature = "with-array")))] | ||
Array(Option<Box<Vec<Value>>>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you think a solution like this will work out:
pub enum Value<A> {
and then this becomes:
Array(Option<Box<Vec<A>>>),
We would have to convert the other code to account for the generic argument, but I'm thinking if such a approach will work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pub enum Value<A> {
So, A
is unbounded? Why is this necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the late reply. Actually, this looks very good!
Hey @tyt2y3, I think something is missing in this PR and it shouldn't be merged into master yet. Binding array values to SQLx PostgreSQL is not ready |
This introduces "Array" as a new Value variant.
It can be derived from all Vec types, where T is a valid Value, except for u8, which is already handled by Bytes.
Note that sqlx and postgres-types already supports an array, so this can be implemented without too much hassle.