Skip to content

Bug: [QueryBuilder] setInsertBatch() + insertBatch() #5674

@iRedds

Description

@iRedds

PHP Version

7.4

CodeIgniter4 Version

dev

CodeIgniter4 Installation Method

Git

Which operating systems have you tested for this bug?

Windows

Which server did you use?

apache

Database

No response

What happened?

When passing data to the setInsertBatch() and insertBatch() methods.

  1. Ignoring batchSize.
  2. Duplicate field(s) in the query string.

Steps to Reproduce

        $db = db_connect();

        $set = [
            ['value' => 1,],
            ['value' => 2,],
            ['value' => 3,],
        ];

        $data = [
            ['value' => 4,],
            ['value' => 5,],
            ['value' => 6,],
        ];

        dd($db->table('test')->testMode()->setInsertBatch($set)->insertBatch($data, null, 1));
array (3) [
    0 => string (66) "INSERT INTO `db_test` (`value`, `value`) VALUES (1), (2), (3), (4)"
    1 => string (42) "INSERT INTO `db_test` (`value`) VALUES (5)"
    2 => string (42) "INSERT INTO `db_test` (`value`) VALUES (6)"
]

Expected Output

array (3) [
    0 => string (42) "INSERT INTO `db_test` (`value`) VALUES (1)"
    1 => string (42) "INSERT INTO `db_test` (`value`) VALUES (2)"
    2 => string (42) "INSERT INTO `db_test` (`value`) VALUES (3)"
    3 => string (42) "INSERT INTO `db_test` (`value`) VALUES (4)"
    4 => string (42) "INSERT INTO `db_test` (`value`) VALUES (5)"
    5 => string (42) "INSERT INTO `db_test` (`value`) VALUES (6)"
]

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugVerified issues on the current code behavior or pull requests that will fix themdatabaseIssues or pull requests that affect the database layer

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions