Table destination with use_auto_increment with batch_size gives a type error

Created on 3 January 2023, over 1 year ago
Updated 15 February 2023, over 1 year ago

Problem/Motivation

If you set a table destination and use auto_increment: true with batch_size: 2 the Table destination plugin errors out on

$this->lastId = (int) $this->dbConnection->query("SELECT MAX($field) AS MaxId FROM {{$this->tableName}}")
            ->fetchField();

because fetchField() returns a string and $this->lastId is expected to be an integer.

Steps to reproduce

The MigrateTableIncrementBatchTest class is meant to test this but $this->batchSize is never used by the parent class.

Proposed resolution

Cast the fetchField() result to an int, remove the check for it not being set (it will be cast to 0 if there's no existing data) fix the test(s), and add a test case where the destination table already has at least one entry to check that the last id is fetched correctly.

Remaining tasks

None

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

6.0

Component

Plugins

Created by

πŸ‡ΈπŸ‡ͺSweden TwoD Sweden

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024