Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BATCH] AUTO_INCREMENT double jumps when inserting int to a varchar column type followed by a string on the last row #291

Open
mavyfaby opened this issue Sep 4, 2024 · 1 comment

Comments

@mavyfaby
Copy link

mavyfaby commented Sep 4, 2024

The problem

As per the title

The table

CREATE TABLE my_table (
    id INT PRIMARY KEY AUTO_INCREMENT,
    other_id INT NOT NULL,
    name VARCHAR(32) NOT NULL,
    value VARCHAR(32) NOT NULL
);

Consider this data

const data = [
    [1, "1.0", 3],
    [1, "2.0", 5],
    [1, "3.0", 6],
    [1, "4.0", 7],
    [1, "5.0", "im a string"],
];

Insertion process

await conn.batch("INSERT INTO my_table (other_id, name, value) VALUES (?, ?, ?)", data);

Result

Current result

The last row auto increment ID doubled, in this case it's 8 (which should be 5)

image

Expected result

image

@mavyfaby
Copy link
Author

:))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant