mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-24 03:45:59 +00:00
SYNC: autocommit WIP
This commit is contained in:
committed by
Diflow
parent
9c7727b7f3
commit
191c25a26b
@@ -25,14 +25,14 @@ function multiTest(testName, testDefinition) {
|
||||
it(testName + ' Mssql', () => testDefinition('Mssql-connection'));
|
||||
}
|
||||
if (localconfig.oracle) {
|
||||
it(testName + ' Oracle', () => testDefinition('Oracle-connection'));
|
||||
it(testName + ' Oracle', () => testDefinition('Oracle-connection', 'C##MY_GUITAR_SHOP'));
|
||||
}
|
||||
}
|
||||
|
||||
describe('Mutli-sql tests', () => {
|
||||
multiTest('Transactions', connectionName => {
|
||||
multiTest('Transactions', (connectionName, databaseName = 'my_guitar_shop') => {
|
||||
cy.contains(connectionName).click();
|
||||
cy.contains('my_guitar_shop').click();
|
||||
cy.contains(databaseName).click();
|
||||
cy.testid('TabsPanel_buttonNewQuery').click();
|
||||
cy.wait(1000);
|
||||
cy.get('body').type("INSERT INTO categories (category_id, category_name) VALUES (5, 'test');");
|
||||
|
||||
1
packages/types/engines.d.ts
vendored
1
packages/types/engines.d.ts
vendored
@@ -164,6 +164,7 @@ export interface EngineDriver<TClient = any> extends FilterBehaviourProvider {
|
||||
profilerChartMeasures?: { label: string; field: string }[];
|
||||
isElectronOnly?: boolean;
|
||||
supportsTransactions?: boolean;
|
||||
implicitTransactions?: boolean; // transaction is started with first SQL command, no BEGIN TRANSACTION is needed
|
||||
|
||||
collectionSingularLabel?: string;
|
||||
collectionPluralLabel?: string;
|
||||
|
||||
@@ -68,6 +68,22 @@
|
||||
testEnabled: () => getCurrentEditor()?.beginTransactionEnabled(),
|
||||
onClick: () => getCurrentEditor().beginTransaction(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'query.autocommitOffSwitch',
|
||||
category: 'Query',
|
||||
name: 'Autocommit: OFF',
|
||||
icon: 'icon transaction',
|
||||
testEnabled: () => getCurrentEditor()?.autocommitOffSwitchEnabled(),
|
||||
onClick: () => getCurrentEditor().autocommitOffSwitch(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'query.autocommitOnSwitch',
|
||||
category: 'Query',
|
||||
name: 'Autocommit: ON',
|
||||
icon: 'icon transaction',
|
||||
testEnabled: () => getCurrentEditor()?.autocommitOnSwitchEnabled(),
|
||||
onClick: () => getCurrentEditor().autocommitOnSwitch(),
|
||||
});
|
||||
registerCommand({
|
||||
id: 'query.commitTransaction',
|
||||
category: 'Query',
|
||||
@@ -178,6 +194,7 @@
|
||||
let isAiAssistantVisible = isProApp() && localStorage.getItem(`tabdata_isAiAssistantVisible_${tabid}`) == 'true';
|
||||
let domAiAssistant;
|
||||
let isInTransaction = false;
|
||||
let isAutocommit = false;
|
||||
|
||||
onMount(() => {
|
||||
intervalId = setInterval(() => {
|
||||
@@ -221,6 +238,7 @@
|
||||
busy;
|
||||
sessionId;
|
||||
isInTransaction;
|
||||
isAutocommit;
|
||||
invalidateCommands();
|
||||
}
|
||||
|
||||
@@ -415,13 +433,29 @@
|
||||
}
|
||||
|
||||
export function beginTransactionEnabled() {
|
||||
return driver?.supportsTransactions && !isInTransaction && !busy;
|
||||
return driver?.supportsTransactions && !driver?.implicitTransactions && !isInTransaction && !busy;
|
||||
}
|
||||
|
||||
export function autocommitOffSwitchEnabled() {
|
||||
return driver?.supportsTransactions && driver?.implicitTransactions && !isInTransaction && !busy && !isAutocommit;
|
||||
}
|
||||
|
||||
export function autocommitOnSwitchEnabled() {
|
||||
return driver?.supportsTransactions && driver?.implicitTransactions && !isInTransaction && !busy && isAutocommit;
|
||||
}
|
||||
|
||||
export function endTransactionEnabled() {
|
||||
return !!sessionId && driver?.supportsTransactions && isInTransaction && !busy;
|
||||
}
|
||||
|
||||
export function autocommitOffSwitch() {
|
||||
isAutocommit = true;
|
||||
}
|
||||
|
||||
export function autocommitOnSwitch() {
|
||||
isAutocommit = false;
|
||||
}
|
||||
|
||||
export function commitTransaction() {
|
||||
const dmp = driver.createDumper();
|
||||
dmp.commitTransaction();
|
||||
@@ -666,6 +700,12 @@
|
||||
data-testid="QueryTab_beginTransactionButton"
|
||||
hideDisabled
|
||||
/>
|
||||
<ToolStripCommandButton command="query.autocommitOnSwitch" data-testid="QueryTab_autocommitOnSwitch" hideDisabled />
|
||||
<ToolStripCommandButton
|
||||
command="query.autocommitOffSwitch"
|
||||
data-testid="QueryTab_autocommitOffSwitch"
|
||||
hideDisabled
|
||||
/>
|
||||
<ToolStripCommandButton
|
||||
command="query.commitTransaction"
|
||||
data-testid="QueryTab_commitTransactionButton"
|
||||
|
||||
@@ -103,6 +103,7 @@ const oracleDriver = {
|
||||
getQuerySplitterOptions: () => oracleSplitterOptions,
|
||||
readOnlySessions: true,
|
||||
supportsTransactions: true,
|
||||
implicitTransactions: true,
|
||||
|
||||
databaseUrlPlaceholder: 'e.g. localhost:1521/orcl',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user