SYNC: SQL fixed database WIP

This commit is contained in:
SPRINX0\prochazka
2025-06-23 13:10:18 +02:00
committed by Diflow
parent d004e6e86c
commit a648f1ee67
4 changed files with 47 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import _ from 'lodash';
import { getCurrentDatabase } from '../stores';
import { getConnectionLabel } from 'dbgate-tools';
import { getConnectionLabel, getSqlFrontMatter, setSqlFrontMatter } from 'dbgate-tools';
import yaml from 'js-yaml';
import openNewTab from '../utility/openNewTab';
export default function newQuery({
@@ -9,6 +10,7 @@ export default function newQuery({
title = undefined,
initialData = undefined,
multiTabIndex = undefined,
fixCurrentConnection = false,
...props
} = {}) {
const currentDb = getCurrentDatabase();
@@ -17,6 +19,16 @@ export default function newQuery({
const tooltip = `${getConnectionLabel(connection)}\n${database}`;
if (fixCurrentConnection && !_.isEmpty(connection)) {
const frontMatter = getSqlFrontMatter(initialData, yaml);
const newFrontMatter = {
...frontMatter,
connectionId: connection._id,
databaseName: database,
};
initialData = setSqlFrontMatter(initialData, newFrontMatter, yaml);
}
openNewTab(
{
title: title || 'Query #',