Skip to content

"TypeError: Cannot read property 'replace' of undefined" on running the cli query command with several SQL statements #6612

@nosteiner

Description

@nosteiner

Issue type:

[x] bug report
[ ] feature request
[ ] documentation issue

Database system/driver:

[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] cockroachdb
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo

TypeORM version:

[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)

Steps to reproduce or a small repository showing the problem:

On running the cli query command with several SQL statements all wrapped with double quotes I receive the following error from the cli-highlight:

> ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli --config ormconfig-migrations.ts "query" "SELECT * FROM folder;
SELECT * FROM sub_folder;"

Running query: SELECT * FROM folder;
SELECT * FROM sub_folder;
Query has been executed. Result: 
Error during query execution:
TypeError: Cannot read property 'replace' of undefined
    at escape (/usr/src/app/node_modules/highlight.js/lib/highlight.js:71:18)
    at Object.highlight (/usr/src/app/node_modules/highlight.js/lib/highlight.js:799:18)
    at Object.highlight (/usr/src/app/node_modules/cli-highlight/src/index.ts:97:21)
    at Function.PlatformTools.highlightJson (/usr/src/app/src/platform/PlatformTools.ts:221:16)
    at Object.<anonymous> (/usr/src/app/src/commands/QueryCommand.ts:55:39)
    at step (/usr/src/app/node_modules/typeorm/node_modules/tslib/tslib.js:141:27)
    at Object.next (/usr/src/app/node_modules/typeorm/node_modules/tslib/tslib.js:122:57)
    at fulfilled (/usr/src/app/node_modules/typeorm/node_modules/tslib/tslib.js:112:62)
    at processTicksAndRejections (internal/process/task_queues.js:85:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] typeorm: `ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli --config ormconfig-migrations.ts "query" "SELECT * FROM folder;
npm ERR! SELECT * FROM sub_folder;"`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] typeorm script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-08-24T13_13_49_857Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] rls:on: `bash src/policies/enable-rls.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] rls:on script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-08-24T13_13_49_873Z-debug.log

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions