From 2ad0921b33340634709087e8198e1920098207d3 Mon Sep 17 00:00:00 2001 From: Anatoly Date: Thu, 19 Jul 2018 02:21:06 +0300 Subject: [PATCH] migrating to typescript --- src/BinaryDataDecoder.ts | 5 +++++ src/DBAccess.ts | 4 ++-- src/ViewGenerator.ts | 3 --- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/BinaryDataDecoder.ts b/src/BinaryDataDecoder.ts index 02af134..0592c1a 100644 --- a/src/BinaryDataDecoder.ts +++ b/src/BinaryDataDecoder.ts @@ -39,6 +39,11 @@ export default async function (conversion: Conversion): Promise { const result: DBAccessQueryResult = await dbAccess.query('BinaryDataDecoder::decodeBinaryData', sql, DBVendors.PG, false, true); + if (result.error) { + // No need to continue if no 'bytea' or 'geometry' columns found. + return conversion; + } + const decodePromises: Promise[] = result.data.rows.map(async (row: any) => { const tableName: string = row.table_name; const columnName: string = row.column_name; diff --git a/src/DBAccess.ts b/src/DBAccess.ts index 5e81e88..8b62a92 100644 --- a/src/DBAccess.ts +++ b/src/DBAccess.ts @@ -144,8 +144,8 @@ export default class DBAccess { // It must be requested from the connections pool. client = vendor === DBVendors.PG ? await this.getPgClient() : await this.getMysqlClient(); } catch (error) { - // Client request failed. - // Must exit the function. + // An error occurred when tried to obtain a client from one of pools. + generateError(this._conversion, `\t--[${ caller }] ${ error }`, sql); return processExitOnError ? process.exit() : { client: client, data: undefined, error: error }; } } diff --git a/src/ViewGenerator.ts b/src/ViewGenerator.ts index 5fe3771..690c98c 100644 --- a/src/ViewGenerator.ts +++ b/src/ViewGenerator.ts @@ -22,7 +22,6 @@ import * as fs from 'fs'; import { Stats } from 'fs'; import * as path from 'path'; import log from './Logger'; -import generateError from './ErrorGenerator'; import Conversion from './Conversion'; import * as migrationStateManager from './MigrationStateManager'; import DBAccess from './DBAccess'; @@ -128,7 +127,6 @@ export default async function(conversion: Conversion): Promise { const showCreateViewResult: DBAccessQueryResult = await dbAccess.query(logTitle, sqlShowCreateView, DBVendors.MYSQL, false, false); if (showCreateViewResult.error) { - generateError(conversion, `\t--[${ logTitle }] ${ showCreateViewResult.error }`, sqlShowCreateView); return; } @@ -136,7 +134,6 @@ export default async function(conversion: Conversion): Promise { const createPgViewResult: DBAccessQueryResult = await dbAccess.query(logTitle, sqlCreatePgView, DBVendors.PG, false, false); if (createPgViewResult.error) { - generateError(conversion, `\t--[${ logTitle }] ${ createPgViewResult.error }`, sqlCreatePgView); return logNotCreatedView(conversion, view, sqlCreatePgView); }