Skip to content
This repository has been archived by the owner on Dec 23, 2021. It is now read-only.

Commit

Permalink
fix: db_helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed Sep 1, 2020
1 parent c43f7b3 commit 184ffd7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/type/db_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,14 @@ export class BaseDBHelper implements DBHelper {
colNameMapper = (v) => v;
}

const fullTableName = buildNameWithQuote(`\`${schema}\``, `\`${tableName}\``);
const fullTableName = buildNameWithQuote(schema, tableName);

const { sqlQuery, count, where, selectedFields } = transformQueryAst(
query,
(col) => buildNameWithQuote(`\`${schema}\``, `\`${tableName}\``, colNameMapper(col))
(col) => buildNameWithQuote(schema, tableName, colNameMapper(col))
);

const sSelects = isEmpty(selectedFields) ? '*' : selectedFields.map((f) => `\`${f}\``).join(', ');

const queryStatement = `SELECT ${sSelects} FROM ${fullTableName} ${sqlQuery};`;
const queryStatement = `SELECT ${isEmpty(selectedFields) ? '*' : selectedFields.join(', ')} FROM ${fullTableName} ${sqlQuery};`;
let countStatement = undefined;

if (count) {
Expand Down Expand Up @@ -110,14 +108,16 @@ export class MySqlDBHelper extends BaseDBHelper {
colNameMapper = (v) => v;
}

const fullTableName = buildName(schema, tableName);
const fullTableName = buildName(`\`${schema}\``, `\`${tableName}\``);

const { sqlQuery, count, where, selectedFields } = transformQueryAst(
query,
(col) => buildName(schema, tableName, colNameMapper(col))
);

const queryStatement = `select ${isEmpty(selectedFields) ? '*' : selectedFields.join(', ')} from ${fullTableName} ${sqlQuery};`;
const sSelects = isEmpty(selectedFields) ? '*' : selectedFields.map((f) => `\`${f}\``).join(', ');

const queryStatement = `select ${sSelects} from ${fullTableName} ${sqlQuery};`;

let countStatement = undefined;

Expand Down

0 comments on commit 184ffd7

Please sign in to comment.