mirror of https://github.com/Fabio286/antares.git
feat(PostgreSQL): edit array and text search fields
This commit is contained in:
parent
964570247f
commit
fc651149b9
|
@ -7,11 +7,19 @@ export const TEXT = [
|
|||
export const LONG_TEXT = [
|
||||
'TEXT',
|
||||
'MEDIUMTEXT',
|
||||
'LONGTEXT',
|
||||
'LONGTEXT'
|
||||
];
|
||||
|
||||
export const ARRAY = [
|
||||
'ARRAY',
|
||||
'ANYARRAY'
|
||||
];
|
||||
|
||||
export const TEXT_SEARCH = [
|
||||
'TSVECTOR',
|
||||
'TSQUERY'
|
||||
];
|
||||
|
||||
export const NUMBER = [
|
||||
'INT',
|
||||
'TINYINT',
|
||||
|
@ -49,6 +57,7 @@ export const TIME = [
|
|||
export const DATETIME = [
|
||||
'DATETIME',
|
||||
'TIMESTAMP',
|
||||
'TIMESTAMP WITHOUT TIME ZONE',
|
||||
'TIMESTAMP WITH TIME ZONE'
|
||||
];
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import { ipcMain } from 'electron';
|
|||
import faker from 'faker';
|
||||
import moment from 'moment';
|
||||
import { sqlEscaper } from 'common/libs/sqlEscaper';
|
||||
import { TEXT, LONG_TEXT, NUMBER, FLOAT, BLOB, BIT, DATE, DATETIME } from 'common/fieldTypes';
|
||||
import { TEXT, LONG_TEXT, ARRAY, TEXT_SEARCH, NUMBER, FLOAT, BLOB, BIT, DATE, DATETIME } from 'common/fieldTypes';
|
||||
import fs from 'fs';
|
||||
|
||||
export default (connections) => {
|
||||
|
@ -68,6 +68,10 @@ export default (connections) => {
|
|||
escapedParam = params.content;
|
||||
else if ([...TEXT, ...LONG_TEXT].includes(params.type))
|
||||
escapedParam = `"${sqlEscaper(params.content)}"`;
|
||||
else if (ARRAY.includes(params.type))
|
||||
escapedParam = `'${params.content}'`;
|
||||
else if (TEXT_SEARCH.includes(params.type))
|
||||
escapedParam = `'${params.content.replaceAll('\'', '\'\'')}'`;
|
||||
else if (BLOB.includes(params.type)) {
|
||||
if (params.content) {
|
||||
const fileBlob = fs.readFileSync(params.content);
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredTriggers.length" class="database-misc">
|
||||
<div v-if="filteredTriggers.length && customizations.triggers" class="database-misc">
|
||||
<details class="accordion">
|
||||
<summary class="accordion-header misc-name" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.trigger}">
|
||||
<i class="misc-icon mdi mdi-18px mdi-folder-cog mr-1" />
|
||||
|
@ -65,7 +65,7 @@
|
|||
</details>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredProcedures.length" class="database-misc">
|
||||
<div v-if="filteredProcedures.length && customizations.routines" class="database-misc">
|
||||
<details class="accordion">
|
||||
<summary class="accordion-header misc-name" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.procedure}">
|
||||
<i class="misc-icon mdi mdi-18px mdi-folder-sync mr-1" />
|
||||
|
@ -93,7 +93,7 @@
|
|||
</details>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredFunctions.length" class="database-misc">
|
||||
<div v-if="filteredFunctions.length && customizations.functions" class="database-misc">
|
||||
<details class="accordion">
|
||||
<summary class="accordion-header misc-name" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.function}">
|
||||
<i class="misc-icon mdi mdi-18px mdi-folder-move mr-1" />
|
||||
|
@ -121,7 +121,7 @@
|
|||
</details>
|
||||
</div>
|
||||
|
||||
<div v-if="filteredSchedulers.length" class="database-misc">
|
||||
<div v-if="filteredSchedulers.length && customizations.schedulers" class="database-misc">
|
||||
<details class="accordion">
|
||||
<summary class="accordion-header misc-name" :class="{'text-bold': breadcrumbs.schema === database.name && breadcrumbs.scheduler}">
|
||||
<i class="misc-icon mdi mdi-18px mdi-folder-clock mr-1" />
|
||||
|
@ -194,6 +194,9 @@ export default {
|
|||
breadcrumbs () {
|
||||
return this.getWorkspace(this.connection.uid).breadcrumbs;
|
||||
},
|
||||
customizations () {
|
||||
return this.getWorkspace(this.connection.uid).customizations;
|
||||
},
|
||||
loadedSchemas () {
|
||||
return this.getLoadedSchemas(this.connection.uid);
|
||||
},
|
||||
|
|
|
@ -173,7 +173,7 @@ import { mimeFromHex } from 'common/libs/mimeFromHex';
|
|||
import { formatBytes } from 'common/libs/formatBytes';
|
||||
import { bufferToBase64 } from 'common/libs/bufferToBase64';
|
||||
import hexToBinary from 'common/libs/hexToBinary';
|
||||
import { TEXT, LONG_TEXT, NUMBER, FLOAT, DATE, TIME, DATETIME, BLOB, BIT } from 'common/fieldTypes';
|
||||
import { TEXT, LONG_TEXT, ARRAY, TEXT_SEARCH, NUMBER, FLOAT, DATE, TIME, DATETIME, BLOB, BIT } from 'common/fieldTypes';
|
||||
import { VueMaskDirective } from 'v-mask';
|
||||
import ConfirmModal from '@/components/BaseConfirmModal';
|
||||
import TextEditor from '@/components/BaseTextEditor';
|
||||
|
@ -225,6 +225,12 @@ export default {
|
|||
return hexToBinary(hex);
|
||||
}
|
||||
|
||||
if (ARRAY.includes(type)) {
|
||||
if (Array.isArray(val))
|
||||
return JSON.stringify(val).replaceAll('[', '{').replaceAll(']', '}');
|
||||
return val;
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
},
|
||||
|
@ -350,7 +356,7 @@ export default {
|
|||
this.editingField = field;
|
||||
this.editingLength = this.fields[field].length;
|
||||
|
||||
if (LONG_TEXT.includes(type)) {
|
||||
if ([...LONG_TEXT, ...ARRAY, ...TEXT_SEARCH].includes(type)) {
|
||||
this.isTextareaEditor = true;
|
||||
this.editingContent = this.$options.filters.typeFormat(content, type);
|
||||
return;
|
||||
|
|
|
@ -100,7 +100,8 @@ module.exports = {
|
|||
paste: 'Paste',
|
||||
tools: 'Tools',
|
||||
variables: 'Variables',
|
||||
processes: 'Processes'
|
||||
processes: 'Processes',
|
||||
database: 'Database'
|
||||
},
|
||||
message: {
|
||||
appWelcome: 'Welcome to Antares SQL Client!',
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
"time_with_time_zone": $date-color,
|
||||
"year": $date-color,
|
||||
"timestamp": $date-color,
|
||||
"timestamp_without_time_zone": $date-color,
|
||||
"timestamp_with_time_zone": $date-color,
|
||||
"bit": $bit-color,
|
||||
"bit_varying": $bit-color,
|
||||
|
@ -72,6 +73,8 @@
|
|||
"interval": $array-color,
|
||||
"array": $array-color,
|
||||
"anyarray": $array-color,
|
||||
"tsvector": $array-color,
|
||||
"tsquery": $array-color,
|
||||
"pg_node_tree": $array-color,
|
||||
"unknown": $unknown-color,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue