mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
supportsTransactions driver parameter
This commit is contained in:
parent
293ef047d0
commit
448c15c308
@ -66,20 +66,20 @@ export const driverBase = {
|
|||||||
return new this.dumperClass(this, options);
|
return new this.dumperClass(this, options);
|
||||||
},
|
},
|
||||||
async script(pool, sql, options: RunScriptOptions) {
|
async script(pool, sql, options: RunScriptOptions) {
|
||||||
if (options?.useTransaction) {
|
if (options?.useTransaction && this.supportsTransactions) {
|
||||||
runCommandOnDriver(pool, this, dmp => dmp.beginTransaction());
|
runCommandOnDriver(pool, this, dmp => dmp.beginTransaction());
|
||||||
}
|
}
|
||||||
for (const sqlItem of splitQuery(sql, this.getQuerySplitterOptions('script'))) {
|
for (const sqlItem of splitQuery(sql, this.getQuerySplitterOptions('script'))) {
|
||||||
try {
|
try {
|
||||||
await this.query(pool, sqlItem, { discardResult: true });
|
await this.query(pool, sqlItem, { discardResult: true });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (options?.useTransaction) {
|
if (options?.useTransaction && this.supportsTransactions) {
|
||||||
runCommandOnDriver(pool, this, dmp => dmp.rollbackTransaction());
|
runCommandOnDriver(pool, this, dmp => dmp.rollbackTransaction());
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (options?.useTransaction) {
|
if (options?.useTransaction && this.supportsTransactions) {
|
||||||
runCommandOnDriver(pool, this, dmp => dmp.commitTransaction());
|
runCommandOnDriver(pool, this, dmp => dmp.commitTransaction());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
1
packages/types/engines.d.ts
vendored
1
packages/types/engines.d.ts
vendored
@ -148,6 +148,7 @@ export interface EngineDriver extends FilterBehaviourProvider {
|
|||||||
profilerChartAggregateFunction?: string;
|
profilerChartAggregateFunction?: string;
|
||||||
profilerChartMeasures?: { label: string; field: string }[];
|
profilerChartMeasures?: { label: string; field: string }[];
|
||||||
isElectronOnly?: boolean;
|
isElectronOnly?: boolean;
|
||||||
|
supportsTransactions?: boolean;
|
||||||
|
|
||||||
collectionSingularLabel?: string;
|
collectionSingularLabel?: string;
|
||||||
collectionPluralLabel?: string;
|
collectionPluralLabel?: string;
|
||||||
|
@ -142,6 +142,7 @@ const driver = {
|
|||||||
title: 'Microsoft SQL Server',
|
title: 'Microsoft SQL Server',
|
||||||
defaultPort: 1433,
|
defaultPort: 1433,
|
||||||
defaultAuthTypeName: 'tedious',
|
defaultAuthTypeName: 'tedious',
|
||||||
|
supportsTransactions: true,
|
||||||
// databaseUrlPlaceholder: 'e.g. server=localhost&authentication.type=default&authentication.type.user=myuser&authentication.type.password=pwd&options.database=mydb',
|
// databaseUrlPlaceholder: 'e.g. server=localhost&authentication.type=default&authentication.type.user=myuser&authentication.type.password=pwd&options.database=mydb',
|
||||||
|
|
||||||
getNewObjectTemplates() {
|
getNewObjectTemplates() {
|
||||||
|
@ -120,6 +120,7 @@ const mysqlDriverBase = {
|
|||||||
authTypeLabel: 'Connection mode',
|
authTypeLabel: 'Connection mode',
|
||||||
defaultAuthTypeName: 'hostPort',
|
defaultAuthTypeName: 'hostPort',
|
||||||
defaultSocketPath: '/var/run/mysqld/mysqld.sock',
|
defaultSocketPath: '/var/run/mysqld/mysqld.sock',
|
||||||
|
supportsTransactions: true,
|
||||||
|
|
||||||
getNewObjectTemplates() {
|
getNewObjectTemplates() {
|
||||||
return [
|
return [
|
||||||
|
@ -97,6 +97,7 @@ const oracleDriver = {
|
|||||||
// ['server', 'port', 'user', 'password', 'defaultDatabase', 'singleDatabase'].includes(field),
|
// ['server', 'port', 'user', 'password', 'defaultDatabase', 'singleDatabase'].includes(field),
|
||||||
getQuerySplitterOptions: () => oracleSplitterOptions,
|
getQuerySplitterOptions: () => oracleSplitterOptions,
|
||||||
readOnlySessions: true,
|
readOnlySessions: true,
|
||||||
|
supportsTransactions: true,
|
||||||
|
|
||||||
databaseUrlPlaceholder: 'e.g. localhost:1521/orcl',
|
databaseUrlPlaceholder: 'e.g. localhost:1521/orcl',
|
||||||
|
|
||||||
|
@ -44,6 +44,7 @@ const driver = {
|
|||||||
engine: 'sqlite@dbgate-plugin-sqlite',
|
engine: 'sqlite@dbgate-plugin-sqlite',
|
||||||
title: 'SQLite',
|
title: 'SQLite',
|
||||||
readOnlySessions: true,
|
readOnlySessions: true,
|
||||||
|
supportsTransactions: true,
|
||||||
showConnectionField: (field, values) => field == 'databaseFile' || field == 'isReadOnly',
|
showConnectionField: (field, values) => field == 'databaseFile' || field == 'isReadOnly',
|
||||||
showConnectionTab: (field) => false,
|
showConnectionTab: (field) => false,
|
||||||
beforeConnectionSave: (connection) => ({
|
beforeConnectionSave: (connection) => ({
|
||||||
|
Loading…
Reference in New Issue
Block a user