Adding media to collection - Server error - too many terms in compound SELECT

System Information
  • Strapi Version: 4.3.4
  • Operating System: Ubuntu 21.04
  • Database: SQLite
  • Node Version: v16.16
  • NPM Version: v8.11.0
  • Yarn Version: 1.22.19

Hi, I’m trying to add around 600 images (already on media manager) to one of my collection type entries but returns server error. Upon further looking, I found on strapi logs a (very) long output related to a sqlite select or update that ends with the following:

'api::event.event' as `related_type` union all select 'images' as `field`, 808 as `file_id`, 501 as `order`, 4 as `related_id`, 'api::event.event' as `related_type` - too many terms in compound SELECT
    at Database.prepare (/root/rafaeljesusaraiva-provas-strapi/node_modules/better-sqlite3/lib/methods/wrappers.js:5:21)
    at Client_BetterSQLite3._query (/root/rafaeljesusaraiva-provas-strapi/node_modules/knex/lib/dialects/better-sqlite3/index.js:30:34)
    at executeQuery (/root/rafaeljesusaraiva-provas-strapi/node_modules/knex/lib/execution/internal/query-executioner.js:37:17)
    at Client_BetterSQLite3.query (/root/rafaeljesusaraiva-provas-strapi/node_modules/knex/lib/client.js:146:12)
    at Runner.query (/root/rafaeljesusaraiva-provas-strapi/node_modules/knex/lib/execution/runner.js:130:36)
    at ensureConnectionCallback (/root/rafaeljesusaraiva-provas-strapi/node_modules/knex/lib/execution/internal/ensure-connection-callback.js:13:17)
    at Runner.ensureConnection (/root/rafaeljesusaraiva-provas-strapi/node_modules/knex/lib/execution/runner.js:307:20)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async Runner.run (/root/rafaeljesusaraiva-provas-strapi/node_modules/knex/lib/execution/runner.js:30:19)
    at async Object.execute (/root/rafaeljesusaraiva-provas-strapi/node_modules/@strapi/database/lib/query/query-builder.js:393:22)

The schema of the content type I’m trying to add the images to is like this:

{
  "kind": "collectionType",
  "collectionName": "events",
  "info": {
    "singularName": "event",
    "pluralName": "events",
    "displayName": "Albuns (Event)",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "hasVideo": {
      "type": "boolean",
      "default": false,
      "required": true
    },
    "images": {
      "type": "media",
      "multiple": true,
      "required": false,
      "allowedTypes": [
        "images"
      ]
    },
    "video": {
      "type": "media",
      "multiple": false,
      "required": false,
      "allowedTypes": [
        "videos"
      ]
    },
    "name": {
      "type": "string",
      "required": true,
      "unique": true
    },
    "slug": {
      "type": "string",
      "required": true,
      "unique": true
    },
    "dateEvent": {
      "type": "date"
    },
    "available": {
      "type": "boolean",
      "default": false,
      "required": true
    },
    "photoSizes": {
      "type": "relation",
      "relation": "manyToMany",
      "target": "api::photo-size.photo-size",
      "inversedBy": "events"
    },
    "seo": {
      "type": "component",
      "repeatable": false,
      "component": "shared.seo"
    },
    "cover": {
      "type": "media",
      "multiple": false,
      "required": true,
      "allowedTypes": [
        "images"
      ]
    },
    "password": {
      "type": "string"
    },
    "isProtected": {
      "type": "boolean",
      "default": false,
      "required": true
    },
    "orderLimit": {
      "type": "date"
    },
    "orderStart": {
      "type": "date"
    }
  }
}