mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat: support to text blob fields
This commit is contained in:
27
package-lock.json
generated
27
package-lock.json
generated
@ -26,7 +26,7 @@
|
|||||||
"marked": "~4.0.19",
|
"marked": "~4.0.19",
|
||||||
"moment": "~2.29.4",
|
"moment": "~2.29.4",
|
||||||
"mysql2": "~2.3.2",
|
"mysql2": "~2.3.2",
|
||||||
"node-firebird": "~0.9.9",
|
"node-firebird": "github:Fabio286/node-firebird",
|
||||||
"pg": "~8.7.1",
|
"pg": "~8.7.1",
|
||||||
"pg-connection-string": "~2.5.0",
|
"pg-connection-string": "~2.5.0",
|
||||||
"pg-query-stream": "~4.2.3",
|
"pg-query-stream": "~4.2.3",
|
||||||
@ -4133,6 +4133,14 @@
|
|||||||
"prebuild-install": "^7.1.0"
|
"prebuild-install": "^7.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/big-integer": {
|
||||||
|
"version": "1.6.51",
|
||||||
|
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
|
||||||
|
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.6"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/big.js": {
|
"node_modules/big.js": {
|
||||||
"version": "5.2.2",
|
"version": "5.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||||
@ -11276,10 +11284,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/node-firebird": {
|
"node_modules/node-firebird": {
|
||||||
"version": "0.9.9",
|
"version": "1.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-0.9.9.tgz",
|
"resolved": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
|
||||||
"integrity": "sha512-nH4zIaglr+/J0E8W9YTiJchpFbjO7gc0ExDtzZmFXp9iLpmyuq+9RFEJoePT2WE39kkx+DNYO7J7TTHBpOmitQ==",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"big-integer": "^1.6.48",
|
||||||
"long": "^4.0.0"
|
"long": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -19902,6 +19910,11 @@
|
|||||||
"prebuild-install": "^7.1.0"
|
"prebuild-install": "^7.1.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"big-integer": {
|
||||||
|
"version": "1.6.51",
|
||||||
|
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
|
||||||
|
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg=="
|
||||||
|
},
|
||||||
"big.js": {
|
"big.js": {
|
||||||
"version": "5.2.2",
|
"version": "5.2.2",
|
||||||
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||||
@ -25348,10 +25361,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node-firebird": {
|
"node-firebird": {
|
||||||
"version": "0.9.9",
|
"version": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
|
||||||
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-0.9.9.tgz",
|
"from": "node-firebird@https://github.com/Fabio286/node-firebird",
|
||||||
"integrity": "sha512-nH4zIaglr+/J0E8W9YTiJchpFbjO7gc0ExDtzZmFXp9iLpmyuq+9RFEJoePT2WE39kkx+DNYO7J7TTHBpOmitQ==",
|
|
||||||
"requires": {
|
"requires": {
|
||||||
|
"big-integer": "^1.6.48",
|
||||||
"long": "^4.0.0"
|
"long": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -135,7 +135,7 @@
|
|||||||
"marked": "~4.0.19",
|
"marked": "~4.0.19",
|
||||||
"moment": "~2.29.4",
|
"moment": "~2.29.4",
|
||||||
"mysql2": "~2.3.2",
|
"mysql2": "~2.3.2",
|
||||||
"node-firebird": "~0.9.9",
|
"node-firebird": "github:Fabio286/node-firebird",
|
||||||
"pg": "~8.7.1",
|
"pg": "~8.7.1",
|
||||||
"pg-connection-string": "~2.5.0",
|
"pg-connection-string": "~2.5.0",
|
||||||
"pg-query-stream": "~4.2.3",
|
"pg-query-stream": "~4.2.3",
|
||||||
|
@ -90,5 +90,6 @@ export const defaults: Customizations = {
|
|||||||
triggerFunctionlanguages: null,
|
triggerFunctionlanguages: null,
|
||||||
parametersLength: false,
|
parametersLength: false,
|
||||||
languages: null,
|
languages: null,
|
||||||
readOnlyMode: false
|
readOnlyMode: false,
|
||||||
|
blobAsText: false
|
||||||
};
|
};
|
||||||
|
@ -90,5 +90,6 @@ export const customizations: Customizations = {
|
|||||||
triggerFunctionlanguages: null,
|
triggerFunctionlanguages: null,
|
||||||
parametersLength: false,
|
parametersLength: false,
|
||||||
languages: null,
|
languages: null,
|
||||||
readOnlyMode: false
|
readOnlyMode: false,
|
||||||
|
blobAsText: true
|
||||||
};
|
};
|
||||||
|
@ -89,4 +89,5 @@ export interface Customizations {
|
|||||||
parametersLength?: boolean;
|
parametersLength?: boolean;
|
||||||
languages?: string[];
|
languages?: string[];
|
||||||
readOnlyMode?: boolean;
|
readOnlyMode?: boolean;
|
||||||
|
blobAsText: boolean;
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ import * as antares from 'common/interfaces/antares';
|
|||||||
import * as firebird from 'node-firebird';
|
import * as firebird from 'node-firebird';
|
||||||
import { AntaresCore } from '../AntaresCore';
|
import { AntaresCore } from '../AntaresCore';
|
||||||
import dataTypes from 'common/data-types/sqlite';
|
import dataTypes from 'common/data-types/sqlite';
|
||||||
import { NUMBER, FLOAT, TIME, DATETIME } from 'common/fieldTypes';
|
|
||||||
|
|
||||||
export class FirebirdSQLClient extends AntaresCore {
|
export class FirebirdSQLClient extends AntaresCore {
|
||||||
private _schema?: string;
|
private _schema?: string;
|
||||||
@ -49,7 +48,7 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
|
|
||||||
async getConnection () {
|
async getConnection () {
|
||||||
return new Promise<firebird.Database>((resolve, reject) => {
|
return new Promise<firebird.Database>((resolve, reject) => {
|
||||||
firebird.attach(this._params, (err, db) => {
|
firebird.attach({ ...this._params, blobAsText: true }, (err, db) => {
|
||||||
if (err) reject(err);
|
if (err) reject(err);
|
||||||
else resolve(db);
|
else resolve(db);
|
||||||
});
|
});
|
||||||
@ -64,7 +63,7 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getStructure (schemas: Set<string>) {
|
async getStructure (_schemas: Set<string>) {
|
||||||
interface ShowTableResult {
|
interface ShowTableResult {
|
||||||
FORMAT: number;
|
FORMAT: number;
|
||||||
NAME: string;
|
NAME: string;
|
||||||
@ -527,10 +526,10 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
const { rows } = await this.raw(sql);
|
const { rows } = await this.raw(sql);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
number: rows[0].version,
|
number: rows[0].VERSION,
|
||||||
name: 'Firebird SQL',
|
name: 'Firebird SQL',
|
||||||
arch: rows[0].protocol,
|
arch: rows[0].PROTOCOL,
|
||||||
os: rows[0].address
|
os: rows[0].ADDRESS
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -696,13 +695,10 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
|
|
||||||
for (const row of res) {
|
for (const row of res) {
|
||||||
for (const key in row) {
|
for (const key in row) {
|
||||||
const fieldData = fields.find(({ alias }) => alias === key);
|
|
||||||
|
|
||||||
if (fieldData.type === 520 && fieldData.subType === 1)// TODO: handle BLOB subType 1
|
|
||||||
row[key] = row[key]?.toString();
|
|
||||||
|
|
||||||
if (Buffer.isBuffer(row[key]))
|
if (Buffer.isBuffer(row[key]))
|
||||||
row[key] = row[key].toString('binary');
|
row[key] = row[key].toString('binary');
|
||||||
|
else if (typeof row[key] === 'function')
|
||||||
|
row[key] = row[key].toString('binary');
|
||||||
}
|
}
|
||||||
|
|
||||||
remappedResponse.push(row);
|
remappedResponse.push(row);
|
||||||
|
@ -81,6 +81,7 @@
|
|||||||
:fields="fieldsObj"
|
:fields="fieldsObj"
|
||||||
:key-usage="keyUsage"
|
:key-usage="keyUsage"
|
||||||
:element-type="elementType"
|
:element-type="elementType"
|
||||||
|
:blob-as-text="blobAsText"
|
||||||
:class="{'selected': selectedRows.includes(row._antares_id)}"
|
:class="{'selected': selectedRows.includes(row._antares_id)}"
|
||||||
:selected="selectedRows.includes(row._antares_id)"
|
:selected="selectedRows.includes(row._antares_id)"
|
||||||
:selected-cell="selectedRows.length === 1 && selectedRows.includes(row._antares_id) ? selectedField : null"
|
:selected-cell="selectedRows.length === 1 && selectedRows.includes(row._antares_id) ? selectedField : null"
|
||||||
@ -182,6 +183,7 @@ const isEditingRow = ref(false);
|
|||||||
|
|
||||||
const workspaceSchema = computed(() => getWorkspace(props.connUid).breadcrumbs.schema);
|
const workspaceSchema = computed(() => getWorkspace(props.connUid).breadcrumbs.schema);
|
||||||
const workspaceClient = computed(() => getWorkspace(props.connUid).client);
|
const workspaceClient = computed(() => getWorkspace(props.connUid).client);
|
||||||
|
const blobAsText = computed(() => getWorkspace(props.connUid).customizations.blobAsText);
|
||||||
|
|
||||||
const primaryField = computed(() => {
|
const primaryField = computed(() => {
|
||||||
const primaryFields = fields.value.filter(field => field.key === 'pri');
|
const primaryFields = fields.value.filter(field => field.key === 'pri');
|
||||||
|
@ -243,7 +243,8 @@ const props = defineProps({
|
|||||||
itemHeight: Number,
|
itemHeight: Number,
|
||||||
elementType: { type: String, default: 'table' },
|
elementType: { type: String, default: 'table' },
|
||||||
selected: { type: Boolean, default: false },
|
selected: { type: Boolean, default: false },
|
||||||
selectedCell: { type: String, default: null }
|
selectedCell: { type: String, default: null },
|
||||||
|
blobAsText: { type: Boolean, default: false }
|
||||||
});
|
});
|
||||||
|
|
||||||
const emit = defineEmits(['update-field', 'select-row', 'contextmenu', 'start-editing', 'stop-editing']);
|
const emit = defineEmits(['update-field', 'select-row', 'contextmenu', 'start-editing', 'stop-editing']);
|
||||||
@ -318,7 +319,7 @@ const inputProps = computed(() => {
|
|||||||
return { type: 'text', mask: datetimeMask };
|
return { type: 'text', mask: datetimeMask };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BLOB.includes(editingType.value))
|
if (BLOB.includes(editingType.value) && !props.blobAsText)
|
||||||
return { type: 'file', mask: false };
|
return { type: 'file', mask: false };
|
||||||
|
|
||||||
if (BOOLEAN.includes(editingType.value))
|
if (BOOLEAN.includes(editingType.value))
|
||||||
@ -398,7 +399,7 @@ const editON = async (field: string) => {
|
|||||||
editingField.value = field;
|
editingField.value = field;
|
||||||
editingLength.value = props.fields[field].length;
|
editingLength.value = props.fields[field].length;
|
||||||
|
|
||||||
if ([...LONG_TEXT, ...ARRAY, ...TEXT_SEARCH].includes(type)) {
|
if ([...LONG_TEXT, ...ARRAY, ...TEXT_SEARCH].includes(type) || (BLOB.includes(type) && props.blobAsText)) {
|
||||||
isTextareaEditor.value = true;
|
isTextareaEditor.value = true;
|
||||||
editingContent.value = typeFormat(content, type);
|
editingContent.value = typeFormat(content, type);
|
||||||
emit('start-editing', field);
|
emit('start-editing', field);
|
||||||
@ -415,7 +416,7 @@ const editON = async (field: string) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BLOB.includes(type)) {
|
if (BLOB.includes(type) && !props.blobAsText) {
|
||||||
isBlobEditor.value = true;
|
isBlobEditor.value = true;
|
||||||
editingContent.value = content || '';
|
editingContent.value = content || '';
|
||||||
fileToUpload.value = null;
|
fileToUpload.value = null;
|
||||||
@ -454,7 +455,7 @@ const editOFF = () => {
|
|||||||
|
|
||||||
isInlineEditor.value[editingField.value] = false;
|
isInlineEditor.value[editingField.value] = false;
|
||||||
let content;
|
let content;
|
||||||
if (!BLOB.includes(editingType.value)) {
|
if (!BLOB.includes(editingType.value) || (BLOB.includes(editingType.value) && props.blobAsText)) {
|
||||||
if ([...DATETIME, ...TIME].includes(editingType.value)) {
|
if ([...DATETIME, ...TIME].includes(editingType.value)) {
|
||||||
if (editingContent.value !== null && editingContent.value.substring(editingContent.value.length - 1) === '.')
|
if (editingContent.value !== null && editingContent.value.substring(editingContent.value.length - 1) === '.')
|
||||||
editingContent.value = editingContent.value.slice(0, -1);
|
editingContent.value = editingContent.value.slice(0, -1);
|
||||||
@ -588,7 +589,7 @@ const typeFormat = (val: string | number | Date | number[], type: string, precis
|
|||||||
return moment(val).isValid() ? moment(val).format(`YYYY-MM-DD HH:mm:ss${datePrecision}`) : val;
|
return moment(val).isValid() ? moment(val).format(`YYYY-MM-DD HH:mm:ss${datePrecision}`) : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (BLOB.includes(type)) {
|
if (BLOB.includes(type) && !props.blobAsText) {
|
||||||
const buff = Buffer.from(val as string);
|
const buff = Buffer.from(val as string);
|
||||||
if (!buff.length) return '';
|
if (!buff.length) return '';
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user