mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
Compare commits
7 Commits
v0.7.22-be
...
v0.7.22-be
Author | SHA1 | Date | |
---|---|---|---|
e9b42c3edb | |||
259d051a21 | |||
876d5ea481 | |||
da56905572 | |||
d698f2798a | |||
9a41511c42 | |||
|
30ada13663 |
18
CHANGELOG.md
18
CHANGELOG.md
@@ -2,6 +2,24 @@
|
||||
|
||||
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
||||
|
||||
### [0.7.22-beta.1](https://github.com/antares-sql/antares/compare/v0.7.22-beta.0...v0.7.22-beta.1) (2024-02-12)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* update dutch translation + fix spelling mistake ([30ada13](https://github.com/antares-sql/antares/commit/30ada13663e88f89beb3dd7291010837059585d5))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* some issues related to previous commit ([259d051](https://github.com/antares-sql/antares/commit/259d051a21e334496d3a52b662f1855ba9a9046d))
|
||||
* unable to edit tables containing SET fields, fixes [#755](https://github.com/antares-sql/antares/issues/755) ([d698f27](https://github.com/antares-sql/antares/commit/d698f2798a2423f86e6d786dd3ab80439b372a08))
|
||||
|
||||
|
||||
### Improvements
|
||||
|
||||
* **MySQL:** improvements in connection handling ([876d5ea](https://github.com/antares-sql/antares/commit/876d5ea48185334e9e2fc981c4282a9c42d22b10))
|
||||
|
||||
### [0.7.22-beta.0](https://github.com/antares-sql/antares/compare/v0.7.21...v0.7.22-beta.0) (2024-02-04)
|
||||
|
||||
|
||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "antares",
|
||||
"version": "0.7.22-beta.0",
|
||||
"version": "0.7.22-beta.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "antares",
|
||||
"version": "0.7.22-beta.0",
|
||||
"version": "0.7.22-beta.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "antares",
|
||||
"productName": "Antares",
|
||||
"version": "0.7.22-beta.0",
|
||||
"version": "0.7.22-beta.1",
|
||||
"description": "A modern, fast and productivity driven SQL client with a focus in UX.",
|
||||
"license": "MIT",
|
||||
"repository": "https://github.com/antares-sql/antares.git",
|
||||
|
@@ -12,6 +12,7 @@ export class MySQLClient extends BaseClient {
|
||||
private _connectionsToCommit: Map<string, mysql.Connection | mysql.PoolConnection>;
|
||||
private _keepaliveTimer: NodeJS.Timer;
|
||||
private _keepaliveMs: number;
|
||||
private sqlMode?: string[];
|
||||
_connection?: mysql.Connection | mysql.Pool;
|
||||
_params: mysql.ConnectionOptions & {schema: string; ssl?: mysql.SslOptions; ssh?: SSHConfig; readonly: boolean};
|
||||
|
||||
@@ -58,6 +59,10 @@ export class MySQLClient extends BaseClient {
|
||||
this._keepaliveMs = 10*60*1000;
|
||||
}
|
||||
|
||||
private get isPool () {
|
||||
return 'getConnection' in this._connection;
|
||||
}
|
||||
|
||||
private _getType (field: mysql.FieldPacket & { columnType?: number; columnLength?: number }) {
|
||||
let name = this.types[field.columnType];
|
||||
let length = field.columnLength;
|
||||
@@ -181,9 +186,32 @@ export class MySQLClient extends BaseClient {
|
||||
|
||||
async connect () {
|
||||
if (!this._poolSize)
|
||||
this._connection = await this.getConnection();
|
||||
this._connection = await this.getSingleConnection();
|
||||
else
|
||||
this._connection = await this.getConnectionPool();
|
||||
|
||||
// ANSI_QUOTES check
|
||||
const [response] = await this._connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\'');
|
||||
this.sqlMode = response[0]?.Value?.split(',');
|
||||
const hasAnsiQuotes = this.sqlMode.includes('ANSI') || this.sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
await this._connection.query(`SET SESSION sql_mode = '${this.sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
|
||||
if (this._params.readonly)
|
||||
await this._connection.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (this._poolSize) {
|
||||
const hasAnsiQuotes = this.sqlMode.includes('ANSI') || this.sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
this._connection.on('connection', conn => {
|
||||
if (this._params.readonly)
|
||||
conn.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
conn.query(`SET SESSION sql_mode = '${this.sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
destroy () {
|
||||
@@ -196,7 +224,7 @@ export class MySQLClient extends BaseClient {
|
||||
}
|
||||
}
|
||||
|
||||
async getConnection () {
|
||||
async getSingleConnection () {
|
||||
const dbConfig = await this.getDbConfig();
|
||||
const connection = await mysql.createConnection({
|
||||
...dbConfig,
|
||||
@@ -208,17 +236,6 @@ export class MySQLClient extends BaseClient {
|
||||
}
|
||||
});
|
||||
|
||||
// ANSI_QUOTES check
|
||||
const [response] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\'');
|
||||
const sqlMode: string[] = response[0]?.Value?.split(',');
|
||||
const hasAnsiQuotes = sqlMode.includes('ANSI') || sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
if (this._params.readonly)
|
||||
await connection.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
await connection.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
@@ -227,6 +244,7 @@ export class MySQLClient extends BaseClient {
|
||||
const connection = mysql.createPool({
|
||||
...dbConfig,
|
||||
connectionLimit: this._poolSize,
|
||||
enableKeepAlive: true,
|
||||
typeCast: (field, next) => {
|
||||
if (field.type === 'DATETIME')
|
||||
return field.string();
|
||||
@@ -235,25 +253,6 @@ export class MySQLClient extends BaseClient {
|
||||
}
|
||||
});
|
||||
|
||||
// ANSI_QUOTES check
|
||||
const [res] = await connection.query<mysql.RowDataPacket[]>('SHOW GLOBAL VARIABLES LIKE \'%sql_mode%\'');
|
||||
const sqlMode: string[] = res[0]?.Value?.split(',');
|
||||
const hasAnsiQuotes = sqlMode.includes('ANSI') || sqlMode.includes('ANSI_QUOTES');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
await connection.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
|
||||
if (this._params.readonly)
|
||||
await connection.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
connection.on('connection', conn => {
|
||||
if (this._params.readonly)
|
||||
conn.query('SET SESSION TRANSACTION READ ONLY');
|
||||
|
||||
if (hasAnsiQuotes)
|
||||
conn.query(`SET SESSION sql_mode = '${sqlMode.filter((m: string) => !['ANSI', 'ANSI_QUOTES'].includes(m)).join(',')}'`);
|
||||
});
|
||||
|
||||
this._keepaliveTimer = setInterval(async () => {
|
||||
await this.keepAlive();
|
||||
}, this._keepaliveMs);
|
||||
@@ -261,6 +260,43 @@ export class MySQLClient extends BaseClient {
|
||||
return connection;
|
||||
}
|
||||
|
||||
async getConnection (args?: antares.QueryParams, retry?: boolean): Promise<mysql.Pool | mysql.PoolConnection | mysql.Connection> {
|
||||
let connection;
|
||||
|
||||
try {
|
||||
if (args && !args.autocommit && args.tabUid) { // autocommit OFF
|
||||
if (this._connectionsToCommit.has(args.tabUid))
|
||||
connection = this._connectionsToCommit.get(args.tabUid);
|
||||
else {
|
||||
connection = await this.getSingleConnection();
|
||||
await connection.query('SET SESSION autocommit=0');
|
||||
this._connectionsToCommit.set(args.tabUid, connection);
|
||||
}
|
||||
}
|
||||
else// autocommit ON
|
||||
connection = this.isPool ? await (this._connection as mysql.Pool).getConnection() : this._connection;
|
||||
|
||||
if (args && args.tabUid && this.isPool) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this._runningConnections.set(args.tabUid, (connection as any).connection.connectionId);
|
||||
}
|
||||
|
||||
if (args && args.schema)
|
||||
await connection.query(`USE \`${args.schema}\``);
|
||||
|
||||
return connection;
|
||||
}
|
||||
catch (error) {
|
||||
if (error.code === 'ECONNRESET' && !retry) {
|
||||
this.destroy();
|
||||
await this.connect();
|
||||
return this.getConnection(args, true);
|
||||
}
|
||||
else
|
||||
throw new Error(error.message);
|
||||
}
|
||||
}
|
||||
|
||||
private async keepAlive () {
|
||||
try {
|
||||
const connection = await (this._connection as mysql.Pool).getConnection();
|
||||
@@ -591,7 +627,7 @@ export class MySQLClient extends BaseClient {
|
||||
return rows.map((field) => {
|
||||
const numLengthMatch = field.COLUMN_TYPE.match(/int\(([^)]+)\)/);
|
||||
const numLength = numLengthMatch ? +numLengthMatch.pop() : field.NUMERIC_PRECISION || null;
|
||||
const enumValues = /(enum)/.test(field.COLUMN_TYPE)
|
||||
const enumValues = /(enum|set)/.test(field.COLUMN_TYPE)
|
||||
? field.COLUMN_TYPE.match(/\(([^)]+)\)/)[0].slice(1, -1)
|
||||
: null;
|
||||
|
||||
@@ -1648,28 +1684,7 @@ export class MySQLClient extends BaseClient {
|
||||
.map(q => q.trim())
|
||||
: [sql];
|
||||
|
||||
let connection: mysql.Connection | mysql.Pool | mysql.PoolConnection;
|
||||
const isPool = 'getConnection' in this._connection;
|
||||
|
||||
if (!args.autocommit && args.tabUid) { // autocommit OFF
|
||||
if (this._connectionsToCommit.has(args.tabUid))
|
||||
connection = this._connectionsToCommit.get(args.tabUid);
|
||||
else {
|
||||
connection = await this.getConnection();
|
||||
await connection.query('SET SESSION autocommit=0');
|
||||
this._connectionsToCommit.set(args.tabUid, connection);
|
||||
}
|
||||
}
|
||||
else// autocommit ON
|
||||
connection = isPool ? await (this._connection as mysql.Pool).getConnection() : this._connection;
|
||||
|
||||
if (args.tabUid && isPool) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this._runningConnections.set(args.tabUid, (connection as any).connection.connectionId);
|
||||
}
|
||||
|
||||
if (args.schema)
|
||||
await connection.query(`USE \`${args.schema}\``);
|
||||
const connection = await this.getConnection(args);
|
||||
|
||||
for (const query of queries) {
|
||||
if (!query) continue;
|
||||
@@ -1729,7 +1744,7 @@ export class MySQLClient extends BaseClient {
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
@@ -1741,7 +1756,7 @@ export class MySQLClient extends BaseClient {
|
||||
keysArr = keysArr ? [...keysArr, ...response] : response;
|
||||
}
|
||||
catch (err) {
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
@@ -1759,7 +1774,7 @@ export class MySQLClient extends BaseClient {
|
||||
keys: keysArr
|
||||
});
|
||||
}).catch((err) => {
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
@@ -1776,7 +1791,7 @@ export class MySQLClient extends BaseClient {
|
||||
});
|
||||
}
|
||||
|
||||
if (isPool && args.autocommit) {
|
||||
if (this.isPool && args.autocommit) {
|
||||
(connection as mysql.PoolConnection).release();
|
||||
this._runningConnections.delete(args.tabUid);
|
||||
}
|
||||
|
@@ -115,7 +115,7 @@
|
||||
<BaseIcon icon-name="mdiHistory" :size="48" />
|
||||
</div>
|
||||
<p class="empty-title h5">
|
||||
{{ t('database.thereIsNoQueriesYet') }}
|
||||
{{ t('database.thereAreNoQueriesYet') }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -382,7 +382,7 @@ const isBaseSelectField = computed(() => {
|
||||
});
|
||||
|
||||
const enumArray = computed(() => {
|
||||
if (props.fields[editingField.value] && props.fields[editingField.value].enumValues)
|
||||
if (props.fields[editingField.value] && props.fields[editingField.value].enumValues && props.fields[editingField.value].type !== 'SET')
|
||||
return props.fields[editingField.value].enumValues.replaceAll('\'', '').split(',');
|
||||
return false;
|
||||
});
|
||||
|
@@ -232,7 +232,7 @@ export const caES = {
|
||||
newFunction: 'Nova funció',
|
||||
newScheduler: 'Nou planificador',
|
||||
newTriggerFunction: 'Nova funció de disparador',
|
||||
thereIsNoQueriesYet: 'Encara no hi ha consultes',
|
||||
thereAreNoQueriesYet: 'Encara no hi ha consultes',
|
||||
searchForQueries: 'Cerca consultes',
|
||||
killProcess: 'Mata procés',
|
||||
exportSchema: 'Exporta esquema',
|
||||
|
@@ -233,7 +233,7 @@ export const csCZ = {
|
||||
newFunction: 'Nová funkce',
|
||||
newScheduler: 'Nový scheduler',
|
||||
newTriggerFunction: 'Nová trigger funkce',
|
||||
thereIsNoQueriesYet: 'Nejsou tu žádné dotazy',
|
||||
thereAreNoQueriesYet: 'Nejsou tu žádné dotazy',
|
||||
searchForQueries: 'Hledání dotazů',
|
||||
killProcess: 'Zabít proces',
|
||||
exportSchema: 'Exportovat schéma',
|
||||
|
@@ -251,7 +251,7 @@ export const enUS = {
|
||||
newFunction: 'New function',
|
||||
newScheduler: 'New scheduler',
|
||||
newTriggerFunction: 'New trigger function',
|
||||
thereIsNoQueriesYet: 'There is no queries yet',
|
||||
thereAreNoQueriesYet: 'There are no queries yet',
|
||||
searchForQueries: 'Search for queries',
|
||||
killProcess: 'Kill process',
|
||||
exportSchema: 'Export schema',
|
||||
|
@@ -229,7 +229,7 @@ export const frFR = {
|
||||
newFunction: 'Nouvelle function',
|
||||
newScheduler: 'Nouveau déclencheur',
|
||||
newTriggerFunction: 'Nouvelle fonction de déclencheur',
|
||||
thereIsNoQueriesYet: 'Il n\'y a pas encore de requête',
|
||||
thereAreNoQueriesYet: 'Il n\'y a pas encore de requête',
|
||||
searchForQueries: 'Rechercher des requêtes',
|
||||
killProcess: 'Terminer un processus',
|
||||
exportSchema: 'Exporter un schéma',
|
||||
|
@@ -227,7 +227,7 @@ export const idID = {
|
||||
newFunction: 'Fungsi baru',
|
||||
newScheduler: 'Penjadwal baru',
|
||||
newTriggerFunction: 'Fungsi pemicu baru',
|
||||
thereIsNoQueriesYet: 'Belum ada kueri',
|
||||
thereAreNoQueriesYet: 'Belum ada kueri',
|
||||
searchForQueries: 'Telusuri kueri',
|
||||
killProcess: 'Membunuh proses',
|
||||
exportSchema: 'Skema ekspor',
|
||||
|
@@ -228,7 +228,7 @@ export const itIT = {
|
||||
newFunction: 'Nuova funzione',
|
||||
newScheduler: 'Nuovo scheduler',
|
||||
newTriggerFunction: 'Nuova funzione di trigger',
|
||||
thereIsNoQueriesYet: 'Non ci sono ancora query',
|
||||
thereAreNoQueriesYet: 'Non ci sono ancora query',
|
||||
searchForQueries: 'Cerca query',
|
||||
killProcess: 'Uccidi processo',
|
||||
exportSchema: 'Esporta schema',
|
||||
|
@@ -198,7 +198,7 @@ export const jaJP = {
|
||||
newFunction: '新しい関数',
|
||||
newScheduler: '新規スケジューラ',
|
||||
newTriggerFunction: '新しいトリガー機能',
|
||||
thereIsNoQueriesYet: 'まだ問い合わせはありません',
|
||||
thereAreNoQueriesYet: 'まだ問い合わせはありません',
|
||||
searchForQueries: 'クエリの検索',
|
||||
killProcess: 'プロセスの停止'
|
||||
},
|
||||
|
@@ -228,7 +228,7 @@ export const koKR = {
|
||||
newFunction: '새 함수',
|
||||
newScheduler: '새 스케줄러',
|
||||
newTriggerFunction: '새 트리거 함수',
|
||||
thereIsNoQueriesYet: '아직 쿼리가 없습니다',
|
||||
thereAreNoQueriesYet: '아직 쿼리가 없습니다',
|
||||
searchForQueries: '쿼리 검색',
|
||||
killProcess: '프로세스 종료',
|
||||
exportSchema: '스키마 내보내기',
|
||||
|
@@ -100,7 +100,7 @@ export const nlNL = {
|
||||
readOnlyMode: 'Alleen lezen modus',
|
||||
untrustedConnection: 'Niet vertrouwde verbinding',
|
||||
allConnections: 'Alle verbindingen',
|
||||
searchForConnections: 'Search for connections'
|
||||
searchForConnections: 'Zoek naar verbindingen'
|
||||
},
|
||||
database: {
|
||||
schema: 'Schema',
|
||||
@@ -233,8 +233,8 @@ export const nlNL = {
|
||||
newFunction: 'Nieuwe function',
|
||||
newScheduler: 'Nieuwe scheduler',
|
||||
newTriggerFunction: 'Nieuwe trigger function',
|
||||
thereIsNoQueriesYet: 'There is no queries yet',
|
||||
searchForQueries: 'Search for queries',
|
||||
thereAreNoQueriesYet: 'Er zijn nog geen queries',
|
||||
searchForQueries: 'Zoek naar queries',
|
||||
killProcess: 'Sluit proces af',
|
||||
exportSchema: 'Exporteer schema',
|
||||
importSchema: 'Importeer schema',
|
||||
|
@@ -231,7 +231,7 @@ export const ptBR = {
|
||||
newFunction: 'Nova função',
|
||||
newScheduler: 'Novo agendento',
|
||||
newTriggerFunction: 'Novo gatinho de função',
|
||||
thereIsNoQueriesYet: 'Nenhuma consulta ainda',
|
||||
thereAreNoQueriesYet: 'Nenhuma consulta ainda',
|
||||
searchForQueries: 'Pesquisar por consultas',
|
||||
killProcess: 'Matar processo',
|
||||
exportSchema: 'Exportar banco de dados',
|
||||
|
@@ -229,7 +229,7 @@ export const ruRU = {
|
||||
newFunction: 'Новая функция',
|
||||
newScheduler: 'Новый планировщик',
|
||||
newTriggerFunction: 'Новая функция триггера',
|
||||
thereIsNoQueriesYet: 'Запросы пока отсутствуют',
|
||||
thereAreNoQueriesYet: 'Запросы пока отсутствуют',
|
||||
searchForQueries: 'Поиск по запросам',
|
||||
killProcess: 'Убить процесс',
|
||||
exportSchema: 'Экспорт схемы',
|
||||
|
@@ -238,7 +238,7 @@ export const ukUA = {
|
||||
newFunction: 'Нова функція',
|
||||
newScheduler: 'Новий планувальник',
|
||||
newTriggerFunction: 'Нова функція тригера',
|
||||
thereIsNoQueriesYet: 'Поки що немає запитів',
|
||||
thereAreNoQueriesYet: 'Поки що немає запитів',
|
||||
searchForQueries: 'Пошук запитів',
|
||||
killProcess: 'Завершити процес',
|
||||
exportSchema: 'Експорт схеми',
|
||||
|
@@ -222,7 +222,7 @@ export const viVN = {
|
||||
newFunction: 'Chức năng mới',
|
||||
newScheduler: 'Bộ lập lịch mới',
|
||||
newTriggerFunction: 'Chức năng kích hoạt mới',
|
||||
thereIsNoQueriesYet: 'Không có truy vấn nào',
|
||||
thereAreNoQueriesYet: 'Không có truy vấn nào',
|
||||
searchForQueries: 'Tìm kiếm truy vấn',
|
||||
killProcess: 'Huỷ quá trình',
|
||||
exportSchema: 'Xuất lược đồ',
|
||||
|
@@ -236,7 +236,7 @@ export const zhCN = {
|
||||
newFunction: '新函数',
|
||||
newScheduler: '新调度器',
|
||||
newTriggerFunction: '新触发器函数',
|
||||
thereIsNoQueriesYet: '目前还没有任何查询',
|
||||
thereAreNoQueriesYet: '目前还没有任何查询',
|
||||
searchForQueries: '搜索查询',
|
||||
killProcess: '终止进程',
|
||||
exportSchema: '导出模式(schema)',
|
||||
|
Reference in New Issue
Block a user