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

Postgres insert json array #8957

Closed
Valdri opened this issue Mar 22, 2024 · 2 comments
Closed

Postgres insert json array #8957

Valdri opened this issue Mar 22, 2024 · 2 comments
Labels
in linear Issue or PR has been created in Linear for internal review Released

Comments

@Valdri
Copy link

Valdri commented Mar 22, 2024

Bug Description

I can't insert data into json[] or jsonb[] data type
n8n returns an error:
ERROR: column "jsona" is of type jsonb[] but expression is of type text[]
image

My workflow file:

{
  "name": "Postgres insert array [DEV]",
  "nodes": [
    {
      "parameters": {},
      "id": "6544500a-ff20-419d-8d26-a9a1154eba7f",
      "name": "When clicking \"Test workflow\"",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        1180,
        680
      ]
    },
    {
      "parameters": {
        "jsCode": "return [\n  {\n    \"translations\": [\n      {\n        \"detected_source_language\": \"EN\",\n        \"text\": \"Przetłumacz również ten tekst\"\n      }\n    ]\n  }\n];"
      },
      "id": "ec045a8c-f71e-43d3-bf3d-0d9ae1398e43",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1400,
        680
      ]
    },
    {
      "parameters": {
        "schema": {
          "__rl": true,
          "mode": "list",
          "value": "public"
        },
        "table": {
          "__rl": true,
          "value": "cache",
          "mode": "list",
          "cachedResultName": "cache"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "MD5": "3dwdwdsdfwsf",
            "jsona": "={{ $json.translations }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "MD5",
              "displayName": "MD5",
              "required": true,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "created_at",
              "displayName": "created_at",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "dateTime",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "json",
              "displayName": "json",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "object",
              "canBeUsedToMatch": true,
              "removed": true
            },
            {
              "id": "jsona",
              "displayName": "jsona",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "array",
              "canBeUsedToMatch": true
            }
          ]
        },
        "options": {}
      },
      "id": "8af82fa7-8084-488e-85f3-6237797a6372",
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2.3,
      "position": [
        1620,
        680
      ],
      "credentials": {
        "postgres": {
          "id": "o1iplAbT58HPPB6f",
          "name": "Postgres deepl_cache"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking \"Test workflow\"": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "7bf83134-6321-468a-8d60-e6f58a3bde9c",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "94bc6053e8ba92fcb47e0c9d1f36fb1b3c6adc1b968554d4a8f0b08b23ced40b"
  },
  "id": "5eXvPYrZbwekfIoG",
  "tags": []
}

To Reproduce

  1. create postgres column with jsonb[] or json[] data type
  2. try to insert json array

Expected behavior

Ability to insert a json array

Operating System

Docker

n8n Version

1.32.2

Node.js Version

Docker

Database

PostgreSQL

Execution mode

queue

@Joffcom
Copy link
Member

Joffcom commented Mar 25, 2024

Hey @Valdri,

Thanks for the report, I have created NODE-1263 to get this updated in the future.

@Joffcom Joffcom added the in linear Issue or PR has been created in Linear for internal review label Mar 25, 2024
@janober
Copy link
Member

janober commented Apr 18, 2024

Fix got released with n8n@1.38.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in linear Issue or PR has been created in Linear for internal review Released
Projects
None yet
Development

No branches or pull requests

3 participants