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