Error on repeat database delete item at array index 21 and beyond

I get an error when doing multiple deletes on the database (Postgres, OS X, Docker, Node JS)

No clue if this is a bug or other error. Just wondering if others have experienced it.

I select table rows with a checkbox and submit to a server action that contains a repeat and deletes every id that gets passed

It works fine and runs a db delete for all the items in the array from index 0 up to and including 20.
SO I can delete the first 21 items , but it always fails on the 22 item ?
Does not make sense that the item with index 21 should be of any other datatype the the preceding
id’s :slight_smile:

From my PG log

2020-07-14 20:15:13.721 UTC [3855] ERROR:  invalid input syntax for integer: "{"21":"491"}"
2020-07-14 20:15:13.721 UTC [3855] STATEMENT:  delete from "ccu" where "ccu_id" = $1
2020-07-14 20:18:40.731 UTC [3870] ERROR:  invalid input syntax for integer: "{"21":"511"}"
2020-07-14 20:18:40.731 UTC [3870] STATEMENT:  delete from "ccu" where "ccu_id" = $1
2020-07-14 20:19:17.298 UTC [3879] ERROR:  invalid input syntax for integer: "{"21":"532"}"
2020-07-14 20:19:17.298 UTC [3879] STATEMENT:  delete from "ccu" where "ccu_id" = $1
2020-07-14 20:28:49.335 UTC [3943] ERROR:  invalid input syntax for integer: "{"21":"77"}"
2020-07-14 20:28:49.335 UTC [3943] STATEMENT:  delete from "ccu" where "ccu_id" = $1

Try setting a value and output the entire array ( {{$_POST.ccu_id}} ) to see what is coming into the server action. If no difference at or around item 20, then sure seems like a bug…albeit a strange one.

Had to disable the repeat for the set value to work…
I don’t get why this is happening ? :upside_down_face:

Data from form:

Array from Serverconnect

Sure looks like it is a bug, especially given how new Node is w/App Connect.

Here is my server action for the soft delete

{
  "meta": {
    "$_POST": [
      {
        "type": "array",
        "name": "ccu_id"
      },
      {
        "type": "text",
        "name": "deleted"
      },
      {
        "type": "array",
        "name": "record",
        "sub": [
          {
            "type": "datetime",
            "name": "NOW_UTC"
          },
          {
            "type": "text",
            "name": "$value"
          }
        ]
      }
    ]
  },
  "exec": {
    "steps": [
      "connections/db",
      {
        "name": "repeatCcuDelete",
        "module": "core",
        "action": "repeat",
        "options": {
          "repeat": "{{$_POST.ccu_id}}",
          "exec": {
            "steps": {
              "name": "updateCcuDeleted",
              "module": "dbupdater",
              "action": "update",
              "options": {
                "connection": "db",
                "sql": {
                  "type": "update",
                  "values": [
                    {
                      "table": "ccu",
                      "column": "active",
                      "type": "boolean",
                      "value": "false"
                    },
                    {
                      "table": "ccu",
                      "column": "updated_at",
                      "type": "datetime",
                      "value": "{{NOW_UTC}}"
                    },
                    {
                      "table": "ccu",
                      "column": "deleted",
                      "type": "boolean",
                      "value": "true"
                    }
                  ],
                  "table": "ccu",
                  "wheres": {
                    "condition": "AND",
                    "rules": [
                      {
                        "id": "ccu_id",
                        "field": "ccu_id",
                        "type": "string",
                        "operator": "equal",
                        "value": "{{$value}}",
                        "data": {
                          "column": "ccu_id"
                        },
                        "operation": "="
                      }
                    ],
                    "conditional": null,
                    "valid": true
                  },
                  "query": "UPDATE ccu\nSET active = 'false', updated_at = :P1 /* {{NOW_UTC}} */, deleted = 'true'\nWHERE ccu_id = :P2 /* {{$value}} */",
                  "params": [
                    {
                      "name": ":P1",
                      "type": "expression",
                      "value": "{{NOW_UTC}}"
                    },
                    {
                      "operator": "equal",
                      "type": "expression",
                      "name": ":P2",
                      "value": "{{$value}}"
                    }
                  ]
                }
              },
              "meta": [
                {
                  "name": "affected",
                  "type": "number"
                }
              ]
            }
          }
        },
        "output": true,
        "meta": [
          {
            "name": "$index",
            "type": "number"
          },
          {
            "name": "$number",
            "type": "number"
          },
          {
            "name": "$name",
            "type": "text"
          },
          {
            "name": "$value",
            "type": "object"
          }
        ],
        "outputType": "array"
      }
    ]
  }
}

Thanks,
We are going to check this.

1 Like

After some research I found out that express uses qs for parsing the querystring and form posts.

It seems to have a default arrayLimit of 20. I did some tests with posting long arrays using querystring and form posts, but I didn’t get the results you get.

I’m sure it is that querstring parser that is causing the problem, but I’m not able to reproduce it and I can’t directly change the code from it.

Try reinstalling the node modules or updating them.