Closed thomasmathews01 closed 1 year ago
The dimensionality of a Postgres array is only a property of individual values, not their type. As the docs note, the ToSql
implementation for Vec<T>
only interoperates with single-dimensional Postgres arrays. You can use the postgres-array crate to work with multi-dimensional arrays.
However, a COPY query is a more standard approach for bulk insert workflows.
I am trying to bulk insert large amounts of data, which consists of small arrays, by using the UNNEST approach to cut down on the RTTs required.
Where my postgres table looks like so:
Using the below postgres function (because postgres otherwise unnests real[][] to real by default, and I need real[])
The below is valid postgresql, and can be executed directly with psql, with the array of values, which are themselves arrays, correctly unnested
But when I try and execute this using the library dynamically, as so:
It fails to correctly understand the type and I get the error:
This was using version 0.7, and the features "with-serde_json-1" & "with-chrono-0_4".