mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat(Firebird SQL): view add/edit/delete support
This commit is contained in:
@ -46,6 +46,8 @@ export const customizations: Customizations = {
|
|||||||
stringsWrapper: '\'',
|
stringsWrapper: '\'',
|
||||||
tableAdd: true,
|
tableAdd: true,
|
||||||
tableSettings: true,
|
tableSettings: true,
|
||||||
|
viewAdd: true,
|
||||||
|
viewSettings: true,
|
||||||
indexes: true,
|
indexes: true,
|
||||||
foreigns: true,
|
foreigns: true,
|
||||||
nullable: true
|
nullable: true
|
||||||
|
@ -615,20 +615,24 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getViewInformations ({ schema, view }: { schema: string; view: string }) {
|
async getViewInformations ({ view }: { schema: string; view: string }) {
|
||||||
const sql = `SELECT "sql" FROM "${schema}".sqlite_master WHERE "type"='view' AND name='${view}'`;
|
const sql = `
|
||||||
|
SELECT rdb$view_source as sql
|
||||||
|
FROM rdb$relations
|
||||||
|
WHERE rdb$relation_name = '${view}'
|
||||||
|
`;
|
||||||
const results = await this.raw(sql);
|
const results = await this.raw(sql);
|
||||||
|
|
||||||
return results.rows.map(row => {
|
return results.rows.map(row => {
|
||||||
return {
|
return {
|
||||||
sql: row.sql.match(/(?<=AS ).*?$/gs)[0],
|
sql: row.SQL,
|
||||||
name: view
|
name: view
|
||||||
};
|
};
|
||||||
})[0];
|
})[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
async dropView (params: { schema: string; view: string }) {
|
async dropView (params: { schema: string; view: string }) {
|
||||||
const sql = `DROP VIEW '${params.view}'`;
|
const sql = `DROP VIEW "${params.view}"`;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +647,7 @@ export class FirebirdSQLClient extends AntaresCore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createView (params: antares.CreateViewParams) {
|
async createView (params: antares.CreateViewParams) {
|
||||||
const sql = `CREATE VIEW '${params.name}' AS ${params.sql}`;
|
const sql = `CREATE VIEW "${params.name}" AS ${params.sql}`;
|
||||||
return await this.raw(sql);
|
return await this.raw(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user