Skip to content

Commit

Permalink
Improve isInsertUpdateOrDeleteStatement and docstring for getRowsModi…
Browse files Browse the repository at this point in the history
…fied.
  • Loading branch information
kevin-dp committed Nov 27, 2023
1 parent dc6bde9 commit 054db7a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion clients/typescript/src/drivers/generic/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ abstract class DatabaseAdapter
abstract exec(statement: Statement): Promise<Row[]>

/**
* @returns The number of rows modified by the last SQL query.
* @returns The number of rows modified by the last insert/update/delete query.
*/
abstract getRowsModified(): number

Expand Down
9 changes: 2 additions & 7 deletions clients/typescript/src/util/statements.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { SqlValue, Statement } from './types'

export function isInsertUpdateOrDeleteStatement(sql: string) {
const tpe = sql.toLowerCase().trimStart()
return (
tpe.startsWith('insert') ||
tpe.startsWith('update') ||
tpe.startsWith('delete')
)
export function isInsertUpdateOrDeleteStatement(stmt: string) {
return /^\s*(insert|update|delete)/i.test(stmt)
}

/**
Expand Down

0 comments on commit 054db7a

Please sign in to comment.