mirror of
https://github.com/Fabio286/antares.git
synced 2025-02-08 07:48:40 +01:00
feat(Firebird SQL): support to blob fields
This commit is contained in:
parent
2c8509ff41
commit
0827a04d61
@ -44,7 +44,7 @@ export const customizations: Customizations = {
|
||||
schemaExport: false,
|
||||
exportByChunks: false,
|
||||
schemaImport: false,
|
||||
tableSettings: false,
|
||||
tableSettings: true,
|
||||
tableOptions: false,
|
||||
tableArray: false,
|
||||
tableRealCount: false,
|
||||
|
@ -77,6 +77,7 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
return null;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||
async getStructure (_schemas: Set<string>) {
|
||||
interface ShowTableResult {
|
||||
FORMAT: number;
|
||||
@ -466,17 +467,17 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
}
|
||||
|
||||
async duplicateTable (params: { schema: string; table: string }) { // TODO: retrive table informations and create a copy
|
||||
const sql = `CREATE TABLE '${params.table}_copy' AS SELECT * FROM '${params.table}'`;
|
||||
const sql = `CREATE TABLE "${params.table}_copy" AS SELECT * FROM "${params.table}"`;
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async truncateTable (params: { schema: string; table: string }) {
|
||||
const sql = `DELETE FROM '${params.table}'`;
|
||||
const sql = `DELETE FROM "${params.table}"`;
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
async dropTable (params: { schema: string; table: string }) {
|
||||
const sql = `DROP TABLE '${params.table}'`;
|
||||
const sql = `DROP TABLE "${params.table}"`;
|
||||
return await this.raw(sql);
|
||||
}
|
||||
|
||||
@ -586,29 +587,29 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
return null;
|
||||
}
|
||||
|
||||
// async commitTab (tabUid: string) {
|
||||
// const connection = this._connectionsToCommit.get(tabUid);
|
||||
// if (connection) {
|
||||
// connection.prepare('COMMIT').run();
|
||||
// return this.destroyConnectionToCommit(tabUid);
|
||||
// }
|
||||
// }
|
||||
async commitTab (tabUid: string) {
|
||||
// const connection = this._connectionsToCommit.get(tabUid);
|
||||
// if (connection) {
|
||||
// connection.prepare('COMMIT').run();
|
||||
// return this.destroyConnectionToCommit(tabUid);
|
||||
// }
|
||||
}
|
||||
|
||||
// async rollbackTab (tabUid: string) {
|
||||
// const connection = this._connectionsToCommit.get(tabUid);
|
||||
// if (connection) {
|
||||
// connection.prepare('ROLLBACK').run();
|
||||
// return this.destroyConnectionToCommit(tabUid);
|
||||
// }
|
||||
// }
|
||||
async rollbackTab (tabUid: string) {
|
||||
// const connection = this._connectionsToCommit.get(tabUid);
|
||||
// if (connection) {
|
||||
// connection.prepare('ROLLBACK').run();
|
||||
// return this.destroyConnectionToCommit(tabUid);
|
||||
// }
|
||||
}
|
||||
|
||||
// destroyConnectionToCommit (tabUid: string) {
|
||||
// const connection = this._connectionsToCommit.get(tabUid);
|
||||
// if (connection) {
|
||||
// connection.close();
|
||||
// this._connectionsToCommit.delete(tabUid);
|
||||
// }
|
||||
// }
|
||||
destroyConnectionToCommit (tabUid: string) {
|
||||
// const connection = this._connectionsToCommit.get(tabUid);
|
||||
// if (connection) {
|
||||
// connection.close();
|
||||
// this._connectionsToCommit.delete(tabUid);
|
||||
// }
|
||||
}
|
||||
|
||||
getSQL () {
|
||||
// LIMIT
|
||||
@ -755,8 +756,26 @@ export class FirebirdSQLClient extends AntaresCore {
|
||||
for (const key in row) {
|
||||
if (Buffer.isBuffer(row[key]))
|
||||
row[key] = row[key].toString('binary');
|
||||
else if (typeof row[key] === 'function')
|
||||
row[key] = row[key].toString('binary');
|
||||
else if (typeof row[key] === 'function') {
|
||||
const result = await new Promise((resolve, reject) => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
row[key]((err: any, _name: string, event: any) => {
|
||||
if (err)
|
||||
return reject(err);
|
||||
|
||||
const buffArr: Buffer[] = [];
|
||||
event.on('data', (chunk: Buffer) => {
|
||||
buffArr.push(chunk);
|
||||
});
|
||||
|
||||
event.on('end', () => {
|
||||
resolve(Buffer.concat(buffArr));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
row[key] = result;
|
||||
}
|
||||
}
|
||||
|
||||
remappedResponse.push(row);
|
||||
|
@ -323,11 +323,13 @@ const getFieldsData = async () => {
|
||||
const { status, response } = await Tables.getTableIndexes(params);
|
||||
|
||||
if (status === 'success') {
|
||||
const indexesObj = response.reduce((acc: {[key: string]: TableIndex[]}, curr: TableIndex) => {
|
||||
acc[curr.name] = acc[curr.name] || [];
|
||||
acc[curr.name].push(curr);
|
||||
return acc;
|
||||
}, {});
|
||||
const indexesObj = response
|
||||
.filter((index: TableIndex) => index.type !== 'FOREIGN KEY')
|
||||
.reduce((acc: {[key: string]: TableIndex[]}, curr: TableIndex) => {
|
||||
acc[curr.name] = acc[curr.name] || [];
|
||||
acc[curr.name].push(curr);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
originalIndexes.value = Object.keys(indexesObj).map(index => {
|
||||
return {
|
||||
|
@ -17,11 +17,14 @@
|
||||
|
||||
&.key-mul,
|
||||
&.key-INDEX,
|
||||
&.key-fk,
|
||||
&.key-KEY {
|
||||
color: limegreen;
|
||||
}
|
||||
|
||||
&.key-fk {
|
||||
color: chocolate;
|
||||
}
|
||||
|
||||
&.key-FULLTEXT {
|
||||
color: mediumvioletred;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user