mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-17 04:00:48 +01:00
feat: support to text blob fields
This commit is contained in:
parent
95bb41e9db
commit
e6f6a022d1
27
package-lock.json
generated
27
package-lock.json
generated
@ -26,7 +26,7 @@
|
||||
"marked": "~4.0.19",
|
||||
"moment": "~2.29.4",
|
||||
"mysql2": "~2.3.2",
|
||||
"node-firebird": "~0.9.9",
|
||||
"node-firebird": "github:Fabio286/node-firebird",
|
||||
"pg": "~8.7.1",
|
||||
"pg-connection-string": "~2.5.0",
|
||||
"pg-query-stream": "~4.2.3",
|
||||
@ -4133,6 +4133,14 @@
|
||||
"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": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||
@ -11276,10 +11284,10 @@
|
||||
}
|
||||
},
|
||||
"node_modules/node-firebird": {
|
||||
"version": "0.9.9",
|
||||
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-0.9.9.tgz",
|
||||
"integrity": "sha512-nH4zIaglr+/J0E8W9YTiJchpFbjO7gc0ExDtzZmFXp9iLpmyuq+9RFEJoePT2WE39kkx+DNYO7J7TTHBpOmitQ==",
|
||||
"version": "1.1.2",
|
||||
"resolved": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
|
||||
"dependencies": {
|
||||
"big-integer": "^1.6.48",
|
||||
"long": "^4.0.0"
|
||||
}
|
||||
},
|
||||
@ -19902,6 +19910,11 @@
|
||||
"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": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/big.js/-/big.js-5.2.2.tgz",
|
||||
@ -25348,10 +25361,10 @@
|
||||
}
|
||||
},
|
||||
"node-firebird": {
|
||||
"version": "0.9.9",
|
||||
"resolved": "https://registry.npmjs.org/node-firebird/-/node-firebird-0.9.9.tgz",
|
||||
"integrity": "sha512-nH4zIaglr+/J0E8W9YTiJchpFbjO7gc0ExDtzZmFXp9iLpmyuq+9RFEJoePT2WE39kkx+DNYO7J7TTHBpOmitQ==",
|
||||
"version": "git+ssh://git@github.com/Fabio286/node-firebird.git#28059a4aff44fc4b9ce69699bb1ad14f837de692",
|
||||
"from": "node-firebird@https://github.com/Fabio286/node-firebird",
|
||||
"requires": {
|
||||
"big-integer": "^1.6.48",
|
||||
"long": "^4.0.0"
|
||||
}
|
||||
},
|
||||
|
@ -135,7 +135,7 @@
|
||||
"marked": "~4.0.19",
|
||||
"moment": "~2.29.4",
|
||||
"mysql2": "~2.3.2",
|
||||
"node-firebird": "~0.9.9",
|
||||
"node-firebird": "github:Fabio286/node-firebird",
|
||||
"pg": "~8.7.1",
|
||||
"pg-connection-string": "~2.5.0",
|
||||
"pg-query-stream": "~4.2.3",
|
||||
|
@ -90,5 +90,6 @@ export const defaults: Customizations = {
|
||||
triggerFunctionlanguages: null,
|
||||
parametersLength: false,
|
||||
languages: null,
|
||||
readOnlyMode: false
|
||||
readOnlyMode: false,
|
||||
blobAsText: false
|
||||
};
|
||||
|
@ -90,5 +90,6 @@ export const customizations: Customizations = {
|
||||
triggerFunctionlanguages: null,
|
||||
parametersLength: false,
|
||||
languages: null,
|
||||
readOnlyMode: false
|
||||
readOnlyMode: false,
|
||||
blobAsText: true
|
||||
};
|
||||
|
@ -89,4 +89,5 @@ export interface Customizations {
|
||||
parametersLength?: boolean;
|
||||
languages?: string[];
|
||||
readOnlyMode?: boolean;
|
||||
blobAsText: boolean;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ import * as antares from 'common/interfaces/antares';
|
||||
import * as firebird from 'node-firebird';
|
||||
import { AntaresCore } from '../AntaresCore';
|
||||
import dataTypes from 'common/data-types/sqlite';
|
||||
import { NUMBER, FLOAT, TIME, DATETIME } from 'common/fieldTypes';
|
||||
|
||||
export class FirebirdSQLClient extends AntaresCore {
|
||||
private _schema?: string;
|
||||
@ -49,7 +48,7 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
|
||||
async getConnection () {
|
||||
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);
|
||||
else resolve(db);
|
||||
});
|
||||
@ -64,7 +63,7 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
return null;
|
||||
}
|
||||
|
||||
async getStructure (schemas: Set<string>) {
|
||||
async getStructure (_schemas: Set<string>) {
|
||||
interface ShowTableResult {
|
||||
FORMAT: number;
|
||||
NAME: string;
|
||||
@ -527,10 +526,10 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
const { rows } = await this.raw(sql);
|
||||
|
||||
return {
|
||||
number: rows[0].version,
|
||||
number: rows[0].VERSION,
|
||||
name: 'Firebird SQL',
|
||||
arch: rows[0].protocol,
|
||||
os: rows[0].address
|
||||
arch: rows[0].PROTOCOL,
|
||||
os: rows[0].ADDRESS
|
||||
};
|
||||
}
|
||||
|
||||
@ -696,13 +695,10 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
|
||||
for (const row of res) {
|
||||
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]))
|
||||
row[key] = row[key].toString('binary');
|
||||
else if (typeof row[key] === 'function')
|
||||
row[key] = row[key].toString('binary');
|
||||
}
|
||||
|
||||
remappedResponse.push(row);
|
||||
|
@ -81,6 +81,7 @@
|
||||
:fields="fieldsObj"
|
||||
:key-usage="keyUsage"
|
||||
:element-type="elementType"
|
||||
:blob-as-text="blobAsText"
|
||||
:class="{'selected': selectedRows.includes(row._antares_id)}"
|
||||
:selected="selectedRows.includes(row._antares_id)"
|
||||
: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 workspaceClient = computed(() => getWorkspace(props.connUid).client);
|
||||
const blobAsText = computed(() => getWorkspace(props.connUid).customizations.blobAsText);
|
||||
|
||||
const primaryField = computed(() => {
|
||||
const primaryFields = fields.value.filter(field => field.key === 'pri');
|
||||
|
@ -243,7 +243,8 @@ const props = defineProps({
|
||||
itemHeight: Number,
|
||||
elementType: { type: String, default: 'table' },
|
||||
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']);
|
||||
@ -318,7 +319,7 @@ const inputProps = computed(() => {
|
||||
return { type: 'text', mask: datetimeMask };
|
||||
}
|
||||
|
||||
if (BLOB.includes(editingType.value))
|
||||
if (BLOB.includes(editingType.value) && !props.blobAsText)
|
||||
return { type: 'file', mask: false };
|
||||
|
||||
if (BOOLEAN.includes(editingType.value))
|
||||
@ -398,7 +399,7 @@ const editON = async (field: string) => {
|
||||
editingField.value = field;
|
||||
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;
|
||||
editingContent.value = typeFormat(content, type);
|
||||
emit('start-editing', field);
|
||||
@ -415,7 +416,7 @@ const editON = async (field: string) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (BLOB.includes(type)) {
|
||||
if (BLOB.includes(type) && !props.blobAsText) {
|
||||
isBlobEditor.value = true;
|
||||
editingContent.value = content || '';
|
||||
fileToUpload.value = null;
|
||||
@ -454,7 +455,7 @@ const editOFF = () => {
|
||||
|
||||
isInlineEditor.value[editingField.value] = false;
|
||||
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 (editingContent.value !== null && editingContent.value.substring(editingContent.value.length - 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;
|
||||
}
|
||||
|
||||
if (BLOB.includes(type)) {
|
||||
if (BLOB.includes(type) && !props.blobAsText) {
|
||||
const buff = Buffer.from(val as string);
|
||||
if (!buff.length) return '';
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user