mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-25 09: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'));
|
it(testName + ' Mssql', () => testDefinition('Mssql-connection'));
|
||||||
}
|
}
|
||||||
if (localconfig.oracle) {
|
if (localconfig.oracle) {
|
||||||
it(testName + ' Oracle', () => testDefinition('Oracle-connection'));
|
it(testName + ' Oracle', () => testDefinition('Oracle-connection', 'C##MY_GUITAR_SHOP'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Mutli-sql tests', () => {
|
describe('Mutli-sql tests', () => {
|
||||||
multiTest('Transactions', connectionName => {
|
multiTest('Transactions', (connectionName, databaseName = 'my_guitar_shop') => {
|
||||||
cy.contains(connectionName).click();
|
cy.contains(connectionName).click();
|
||||||
cy.contains('my_guitar_shop').click();
|
cy.contains(databaseName).click();
|
||||||
cy.testid('TabsPanel_buttonNewQuery').click();
|
cy.testid('TabsPanel_buttonNewQuery').click();
|
||||||
cy.wait(1000);
|
cy.wait(1000);
|
||||||
cy.get('body').type("INSERT INTO categories (category_id, category_name) VALUES (5, 'test');");
|
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 }[];
|
profilerChartMeasures?: { label: string; field: string }[];
|
||||||
isElectronOnly?: boolean;
|
isElectronOnly?: boolean;
|
||||||
supportsTransactions?: boolean;
|
supportsTransactions?: boolean;
|
||||||
|
implicitTransactions?: boolean; // transaction is started with first SQL command, no BEGIN TRANSACTION is needed
|
||||||
|
|
||||||
collectionSingularLabel?: string;
|
collectionSingularLabel?: string;
|
||||||
collectionPluralLabel?: string;
|
collectionPluralLabel?: string;
|
||||||
|
|||||||
@@ -68,6 +68,22 @@
|
|||||||
testEnabled: () => getCurrentEditor()?.beginTransactionEnabled(),
|
testEnabled: () => getCurrentEditor()?.beginTransactionEnabled(),
|
||||||
onClick: () => getCurrentEditor().beginTransaction(),
|
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({
|
registerCommand({
|
||||||
id: 'query.commitTransaction',
|
id: 'query.commitTransaction',
|
||||||
category: 'Query',
|
category: 'Query',
|
||||||
@@ -178,6 +194,7 @@
|
|||||||
let isAiAssistantVisible = isProApp() && localStorage.getItem(`tabdata_isAiAssistantVisible_${tabid}`) == 'true';
|
let isAiAssistantVisible = isProApp() && localStorage.getItem(`tabdata_isAiAssistantVisible_${tabid}`) == 'true';
|
||||||
let domAiAssistant;
|
let domAiAssistant;
|
||||||
let isInTransaction = false;
|
let isInTransaction = false;
|
||||||
|
let isAutocommit = false;
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
intervalId = setInterval(() => {
|
intervalId = setInterval(() => {
|
||||||
@@ -221,6 +238,7 @@
|
|||||||
busy;
|
busy;
|
||||||
sessionId;
|
sessionId;
|
||||||
isInTransaction;
|
isInTransaction;
|
||||||
|
isAutocommit;
|
||||||
invalidateCommands();
|
invalidateCommands();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,13 +433,29 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function beginTransactionEnabled() {
|
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() {
|
export function endTransactionEnabled() {
|
||||||
return !!sessionId && driver?.supportsTransactions && isInTransaction && !busy;
|
return !!sessionId && driver?.supportsTransactions && isInTransaction && !busy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function autocommitOffSwitch() {
|
||||||
|
isAutocommit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function autocommitOnSwitch() {
|
||||||
|
isAutocommit = false;
|
||||||
|
}
|
||||||
|
|
||||||
export function commitTransaction() {
|
export function commitTransaction() {
|
||||||
const dmp = driver.createDumper();
|
const dmp = driver.createDumper();
|
||||||
dmp.commitTransaction();
|
dmp.commitTransaction();
|
||||||
@@ -666,6 +700,12 @@
|
|||||||
data-testid="QueryTab_beginTransactionButton"
|
data-testid="QueryTab_beginTransactionButton"
|
||||||
hideDisabled
|
hideDisabled
|
||||||
/>
|
/>
|
||||||
|
<ToolStripCommandButton command="query.autocommitOnSwitch" data-testid="QueryTab_autocommitOnSwitch" hideDisabled />
|
||||||
|
<ToolStripCommandButton
|
||||||
|
command="query.autocommitOffSwitch"
|
||||||
|
data-testid="QueryTab_autocommitOffSwitch"
|
||||||
|
hideDisabled
|
||||||
|
/>
|
||||||
<ToolStripCommandButton
|
<ToolStripCommandButton
|
||||||
command="query.commitTransaction"
|
command="query.commitTransaction"
|
||||||
data-testid="QueryTab_commitTransactionButton"
|
data-testid="QueryTab_commitTransactionButton"
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ const oracleDriver = {
|
|||||||
getQuerySplitterOptions: () => oracleSplitterOptions,
|
getQuerySplitterOptions: () => oracleSplitterOptions,
|
||||||
readOnlySessions: true,
|
readOnlySessions: true,
|
||||||
supportsTransactions: true,
|
supportsTransactions: true,
|
||||||
|
implicitTransactions: true,
|
||||||
|
|
||||||
databaseUrlPlaceholder: 'e.g. localhost:1521/orcl',
|
databaseUrlPlaceholder: 'e.g. localhost:1521/orcl',
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user