Skip to content

Error when inserting multiple records with returning last inserted id (mysql2) #130

@kir4ik

Description

@kir4ik

Hi

When using the mysql2 driver and executing an INSERT query with returningLastInsertedId, I encounter the following behavior:

  • If I insert a single record, the ID is returned as expected.
  • However, when attempting to insert multiple records, an error occurs due to the structure of the response from the mysql2 driver.

In the method AbstractQueryRunner.executeInsertReturningMultipleLastInsertedId, the code expects rows to be an array. However, the mysql2 driver returns an object containing the insert information. As a result, I receive the following error:

rows.map is not a function

The screenshot attached shows the response object received from the mysql2 driver in the top left corner.

Steps to Reproduce:

  • Use the mysql2 driver.
  • Attempt to insert multiple records with returningLastInsertedId.

Expected Behavior: executeInsertReturningMultipleLastInsertedId should correctly handle the response when inserting multiple records.

Actual Behavior: An error occurs because the response is an object, and rows.map fails.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions