You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, due to the way we interface with postgres via sqlx, their Encode trait does not allow encoding types containing slices (or things that deref to slices) of other custom types that implement Encode. I am not sure if we can solve this without changing sqlx.
Expected behavior
The array should be generated and inserted into the database
Environment (please complete the following information):
OS: any
Version: 0.5.5
Additional context
The problem stems from the implementation of the Encode trait that appears not recurse into array elements. Even if we tried changing our code to construct the "correct" types before insertion, we'd run into the requirement of constructing a value of an arbitrary type. To see why this is the case, consider that arrays can nest any number of levels. So we'd need at least to be able to construct a Vec<i32>, a Vec<Vec<i32>>, a Vec<Vec<Vec<i32>>>, etc. ad infinitum (and also any other type). Given that sqlx does not have Encode for Box<dyn Encode>, we could not even try using trait objects to overcome that issue.
The text was updated successfully, but these errors were encountered:
Describe the bug
Currently, due to the way we interface with postgres via sqlx, their
Encode
trait does not allow encoding types containing slices (or things that deref to slices) of other custom types that implementEncode
. I am not sure if we can solve this without changing sqlx.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The array should be generated and inserted into the database
Environment (please complete the following information):
Additional context
The problem stems from the implementation of the
Encode
trait that appears not recurse into array elements. Even if we tried changing our code to construct the "correct" types before insertion, we'd run into the requirement of constructing a value of an arbitrary type. To see why this is the case, consider that arrays can nest any number of levels. So we'd need at least to be able to construct aVec<i32>
, aVec<Vec<i32>>
, aVec<Vec<Vec<i32>>>
, etc. ad infinitum (and also any other type). Given that sqlx does not haveEncode
forBox<dyn Encode>
, we could not even try using trait objects to overcome that issue.The text was updated successfully, but these errors were encountered: