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

Inserting into PostgreSQL array columns are broken on master branch #5365

Closed
cjmaio opened this issue Oct 20, 2022 · 1 comment · Fixed by #5439
Closed

Inserting into PostgreSQL array columns are broken on master branch #5365

cjmaio opened this issue Oct 20, 2022 · 1 comment · Fixed by #5439

Comments

@cjmaio
Copy link

cjmaio commented Oct 20, 2022

Environment

Knex version: master
Database + version: PostgreSQL 12.6
OS: Ubuntu 18.04

Bug

  1. Explain what kind of behaviour you are getting and how you think it should do

Using knex to insert an array into a PostgreSQL array column causes the array to be stringified, whereas node-pg expects it to be an array type. This looks to be introduced by #5321

  1. Error message
 "error": "malformed array literal: \"[\"78a50219-9262-4d6f-86ab-b14734440679\"]\"",
  1. Reduced test code, for example in https://npm.runkit.com/knex or if it needs real
    database connection to MySQL or PostgreSQL, then single file example which initializes
    needed data and demonstrates the problem.

Given a table with the structure:

CREATE TABLE foo (
  foo_id uuid NOT NULL DEFAULT uuid_generate_v4() PRIMARY KEY,
  numbers integer[]
);
knex(.insert({
  numbers: [1, 2, 3]
}).into('foo').toSQL().toNative();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants