diff --git a/lib/connectors/sqlite3-connector.ts b/lib/connectors/sqlite3-connector.ts index 3575afa..1ec8542 100644 --- a/lib/connectors/sqlite3-connector.ts +++ b/lib/connectors/sqlite3-connector.ts @@ -76,6 +76,10 @@ export class SQLite3Connector implements Connector { }; } + if (queryDescription.type === "select") { + return []; + } + return { affectedRows: this._client.changes }; } diff --git a/tests/units/queries/sqlite/response.test.ts b/tests/units/queries/sqlite/response.test.ts index bf6db98..7238e2d 100644 --- a/tests/units/queries/sqlite/response.test.ts +++ b/tests/units/queries/sqlite/response.test.ts @@ -38,6 +38,15 @@ Deno.test("SQLite: Response model", async () => { "Insert response", ); + const selectResponse = await Article.select("id") + .where({ title: "Hello world!" }).get(); + + assertEquals( + JSON.stringify(selectResponse), + JSON.stringify([{ id: 1 }]), + "Expected one article", + ); + const updateResponse = await Article.where({ id: 1 }) .update({ title: "Hello there!" }); @@ -84,5 +93,13 @@ Deno.test("SQLite: Response model", async () => { "Delete many records response", ); + const selectEmptyResponse = await Article.all(); + + assertEquals( + JSON.stringify(selectEmptyResponse), + JSON.stringify([]), + "Select expected empty response", + ); + await connection.close(); });