Skip to content

Commit

Permalink
hotfix: sqlite_sequence does not exist when database first created
Browse files Browse the repository at this point in the history
  • Loading branch information
invisal committed Feb 8, 2024
1 parent a864502 commit a8bb030
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/drivers/DatabaseDriver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,20 @@ export default class DatabaseDriver {
}));

// Check auto increment
const seqCount = await this.query(
`SELECT COUNT(*) AS total FROM sqlite_sequence WHERE name=${escapeSqlValue(
tableName
)};`
);

let hasAutoIncrement = false;
const seqRow = seqCount.rows[0];
if (seqRow && Number(seqRow[0] ?? 0) > 0) {
hasAutoIncrement = true;
}

try {
const seqCount = await this.query(
`SELECT COUNT(*) AS total FROM sqlite_sequence WHERE name=${escapeSqlValue(
tableName
)};`
);

const seqRow = seqCount.rows[0];
if (seqRow && Number(seqRow[0] ?? 0) > 0) {
hasAutoIncrement = true;
}
} catch {}

return {
columns,
Expand Down

0 comments on commit a8bb030

Please sign in to comment.