Skip to content

The best way to insert multidimensional numeric array #1891

Answered by jackc
akatasonov asked this question in Q&A
Discussion options

You must be logged in to vote

In PostgreSQL there are two formats that most values can be encoded, text and binary. For normal queries, such as produced by Query and Exec, PostgreSQL allows choosing the format per value. When pgx detects your underlying data is a string it simply passes it to PostgreSQL as-is.

However, the COPY protocol requires all values to be encoded in the same format. pgx's CopyFrom only supports the binary format. It already tried to parse strings to values that can then be encoded into the binary format. But it didn't handle types such as []string that aren't strings but that can be encoded as text and then parsed and converted to binary. It now does.

Try master and it should work.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@akatasonov
Comment options

Answer selected by akatasonov
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants