Skip to content

Commit

Permalink
fix: fixed id not being returned from sqlite driver, and remove cassa…
Browse files Browse the repository at this point in the history
…ndras startwith function
  • Loading branch information
StasiumDev committed Oct 26, 2023
1 parent 7518184 commit 326dc3c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions src/drivers/CassandraDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,24 @@ export class CassandraDriver implements IRemoteDriver {
this.checkConnection();

const queryResult = await this._client!.execute(
`SELECT * FROM ${table} WHERE id LIKE ?`,
[`${query}%`],
`SELECT * FROM ${table}`,
{ prepare: true }
);

return queryResult.rows.map((row) => ({
id: row.id,
value: JSON.parse(row.value),
}));
const result = [];

for (const row of queryResult.rows) {
if (!row.id.startsWith(query)) {
continue;
}

result.push({
id: row.id,
value: JSON.parse(row.value),
});
}

return result;
}

public async getRowByKey<T>(
Expand Down
2 changes: 1 addition & 1 deletion src/drivers/SqliteDriver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class SqliteDriver implements IDriver {
query: string
): Promise<{ id: string; value: any }[]> {
const prep = this._database.prepare(
`SELECT json FROM ${table} WHERE ID LIKE '${query}%'`
`SELECT * FROM ${table} WHERE id LIKE '${query}%'`
);

const data = [];
Expand Down

0 comments on commit 326dc3c

Please sign in to comment.