Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ class MySQLCassette {
`;
}
updateAutoIncrementSql(table, column) {
return `ALTER TABLE ${table} AUTO_INCREMENT = ? + 1`;
return `ALTER TABLE ${table} AUTO_INCREMENT = ?`;
Comment on lines -270 to +272
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MySQLではプレースホルダを使った計算式はエラーが出るようなので、+1を削除しました。
updateAutoIncrement の方で、MySQLCassetteの場合のみ、count+1するようにしました。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

既存のSQLiteチャレンジでも、影響なく正常に動作することを確認です。

}
lastValueSql(table, idCol) {
return `SELECT * FROM ${table} WHERE ${idCol} = LAST_INSERT_ID()`;
Expand Down Expand Up @@ -594,6 +594,9 @@ class Connection {

async updateAutoIncrement(table, column, count) {
const sql = this._cassette.updateAutoIncrementSql(table, column);
if (this._cassette instanceof MySQLCassette) {
count = (count || 0) + 1;
}
return await this.query(sql, [count]);
}

Expand Down