Skip to content

Commit

Permalink
fix: Handle undefined querysets in QueryCommand (#6910)
Browse files Browse the repository at this point in the history
fixes #6612
  • Loading branch information
imnotjames committed Oct 16, 2020
1 parent 920e781 commit 6f285dc
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/commands/QueryCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,13 @@ export class QueryCommand implements yargs.CommandModule {
queryRunner = connection.createQueryRunner();
console.log(chalk.green("Running query: ") + PlatformTools.highlightSql(args._[1]));
const queryResult = await queryRunner.query(args._[1]);
console.log(chalk.green("Query has been executed. Result: "));
console.log(PlatformTools.highlightJson(JSON.stringify(queryResult, undefined, 2)));

if (typeof queryResult === "undefined") {
console.log(chalk.green("Query has been executed. No result was returned."));
} else {
console.log(chalk.green("Query has been executed. Result: "));
console.log(PlatformTools.highlightJson(JSON.stringify(queryResult, undefined, 2)));
}

await queryRunner.release();
await connection.close();
Expand Down

0 comments on commit 6f285dc

Please sign in to comment.