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

Commit

Permalink
feat: update mysql db helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Soontao committed Sep 1, 2020
1 parent 13066dd commit c43f7b3
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/type/db_helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,16 @@ 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 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;

if (count) {
Expand Down

0 comments on commit c43f7b3

Please sign in to comment.