mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-07-20 04:11:56 +08:00
@@ -47,9 +47,15 @@ describe('sqlEditorTransaction', () => {
|
||||
])).toBe(false);
|
||||
});
|
||||
|
||||
it('keeps Trino DML on the plain multi-statement execution path', () => {
|
||||
expect(shouldUseSqlEditorManagedTransactionForType('trino', [
|
||||
'UPDATE hive.default.orders SET status = \'done\'',
|
||||
it.each([
|
||||
['trino', 'UPDATE hive.default.orders SET status = \'done\''],
|
||||
['tdengine', 'INSERT INTO meters(ts, current) VALUES (NOW, 10.2)'],
|
||||
['clickhouse', 'INSERT INTO events FORMAT JSONEachRow {"id":1}'],
|
||||
['iotdb', 'INSERT INTO root.ln.wf01.wt01(timestamp,status) VALUES(1,true)'],
|
||||
])('keeps %s writes on the plain multi-statement execution path', (dbType, sql) => {
|
||||
expect(shouldUseSqlEditorManagedTransactionForType(dbType, [sql])).toBe(false);
|
||||
expect(canReusePendingSqlEditorTransactionForType(dbType, [
|
||||
'SELECT * FROM users WHERE id = 1',
|
||||
])).toBe(false);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,16 @@
|
||||
const SQL_EDITOR_DML_KEYWORDS = new Set(['insert', 'update', 'delete', 'replace', 'merge', 'upsert']);
|
||||
const SQL_EDITOR_READ_KEYWORDS = new Set(['select', 'with', 'show', 'describe', 'desc', 'explain', 'pragma', 'values']);
|
||||
const SQL_EDITOR_TRANSACTION_CONTROL_KEYWORDS = new Set(['begin', 'commit', 'rollback', 'savepoint', 'release']);
|
||||
const SQL_EDITOR_MANAGED_TRANSACTION_UNSUPPORTED_TYPES = new Set([
|
||||
'trino',
|
||||
'tdengine',
|
||||
'clickhouse',
|
||||
'iotdb',
|
||||
'rocketmq',
|
||||
'mqtt',
|
||||
'kafka',
|
||||
'rabbitmq',
|
||||
]);
|
||||
|
||||
type SqlEditorWithAnalysis = {
|
||||
keyword: string;
|
||||
@@ -253,7 +263,7 @@ export const shouldUseSqlEditorManagedTransactionForType = (
|
||||
type: string,
|
||||
statements: string[],
|
||||
): boolean => {
|
||||
if (String(type || '').trim().toLowerCase() === 'trino') {
|
||||
if (SQL_EDITOR_MANAGED_TRANSACTION_UNSUPPORTED_TYPES.has(String(type || '').trim().toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
let hasManagedWrite = false;
|
||||
@@ -279,7 +289,7 @@ export const canReusePendingSqlEditorTransactionForType = (
|
||||
type: string,
|
||||
statements: string[],
|
||||
): boolean => {
|
||||
if (String(type || '').trim().toLowerCase() === 'trino') {
|
||||
if (SQL_EDITOR_MANAGED_TRANSACTION_UNSUPPORTED_TYPES.has(String(type || '').trim().toLowerCase())) {
|
||||
return false;
|
||||
}
|
||||
let hasReadStatement = false;
|
||||
|
||||
Reference in New Issue
Block a user