Skip to content

Commit

Permalink
fix: support DeleteResult in SQLiteDriver (#8237)
Browse files Browse the repository at this point in the history
  • Loading branch information
imnotjames authored Oct 2, 2021
1 parent d7d19e9 commit b678807
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/driver/sqlite/SqliteQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ export class SqliteQueryRunner extends AbstractSqliteQueryRunner {
const databaseConnection = await this.connect();
this.driver.connection.logger.logQuery(query, parameters, this);
const queryStartTime = +new Date();
const isInsertQuery = query.substr(0, 11) === "INSERT INTO";
const isInsertQuery = query.startsWith("INSERT ");
const isDeleteQuery = query.startsWith("DELETE ");
const isUpdateQuery = query.startsWith("UPDATE ");

const execute = async () => {
if (isInsertQuery) {
databaseConnection.run(query, parameters, handler);
if (isInsertQuery || isDeleteQuery || isUpdateQuery) {
await databaseConnection.run(query, parameters, handler);
} else {
databaseConnection.all(query, parameters, handler);
await databaseConnection.all(query, parameters, handler);
}
};

Expand Down
5 changes: 2 additions & 3 deletions test/functional/query-builder/delete/query-builder-delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,8 @@ describe("query builder > delete", () => {

it("should return correct delete result", () => Promise.all(connections.map(async connection => {

// don't run test for sqlite and sqljs as they don't return affected rows
// better-sqlite3 works correctly
if (connection.name === "sqlite" || connection.name === "sqljs" || connection.name === "sap")
// don't run test for SAP Hana as it won't return these
if (connection.name === "sap")
return;

// save some users
Expand Down

0 comments on commit b678807

Please sign in to comment.