mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 21:16:00 +00:00
SYNC: SQL fixed database WIP
This commit is contained in:
committed by
Diflow
parent
d004e6e86c
commit
a648f1ee67
@@ -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 #',
|
||||
|
||||
Reference in New Issue
Block a user