Skip to content

"Unknown argument" error using TypeORM CLI #6896

@mdurling

Description

@mdurling

Issue type:
This used to work until recently:

node --require ts-node/register ../node_modules/typeorm/cli.js query "select count(*) from users" 
typeorm query

Executes given SQL query on a default connection. Specify connection name to run
query on a specific connection.

Options:
  -h, --help        Show help                                          [boolean]
  -c, --connection  Name of the connection on which to run a query.
                                                            [default: "default"]
  -f, --config      Name of the file with connection configuration.
                                                          [default: "ormconfig"]
  -v, --version     Show version number                                [boolean]

Unknown argument: select count(*) from metrics

Now, -- must be used to avoid this error which is problematic when trying to run this via yarn/npm scripts.

node --require ts-node/register ../node_modules/typeorm/cli.js query -- "select count(*) from users" 
Running query: select count(*) from users
Query has been executed. Result:
[
  {
    "count": 104
  }
]

[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:

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