Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/core/engine/wasm/WasmDatabaseEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type {
ColumnDefinition
} from '../../types';
import { escapeIdentifier, validateSqlType, validateRowId, validateRowIds } from '../../sql-utils';
import { crypto } from '../../../platform/cryptoShim';
import { buildSelectQuery, buildCountQuery } from '../../query-builder';
import { applyMergePatch, computeJsonPatchUndo } from '../../json-utils';
import { getNodeFs } from '../../platform/fs';
Expand Down Expand Up @@ -101,7 +102,7 @@ export class WasmDatabaseEngine implements DatabaseOperations {
* Build a quoted SAVEPOINT name that is unique enough for nested engine work.
*/
private createSavepointName(prefix: string): string {
return escapeIdentifier(`${prefix}_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`);
return escapeIdentifier(`${prefix}_${crypto.randomUUID().replace(/-/g, '')}`);
}

/**
Expand Down Expand Up @@ -837,7 +838,7 @@ export class WasmDatabaseEngine implements DatabaseOperations {
// safely from within an outer transaction (e.g., undoColumnDrop).
// escapeIdentifier wraps in double quotes defensively — the generated name
// is already [a-zA-Z0-9_] safe, but quoting prevents issues if the pattern changes.
const savepointName = escapeIdentifier(`sp_${Date.now()}_${Math.random().toString(36).slice(2, 8)}`);
const savepointName = this.createSavepointName('sp_update_batch');
await this.executeQuery(`SAVEPOINT ${savepointName}`);
try {
const escapedTable = escapeIdentifier(table);
Expand Down
Loading