TypeORM迁移:运行Oracle别名问题
我正在使用带有Oracle数据库的TypeORM。当我添加迁移并运行TypeORM迁移:运行Oracle别名问题,oracle,typeorm,Oracle,Typeorm,我正在使用带有Oracle数据库的TypeORM。当我添加迁移并运行typeorm migration:run时,我得到以下输出: bash-4.4$ typeorm migration:run query: SELECT "TABLE_NAME" FROM "USER_TABLES" WHERE "TABLE_NAME" = 'migrations' query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC typeor
typeorm migration:run
时,我得到以下输出:
bash-4.4$ typeorm migration:run
query: SELECT "TABLE_NAME" FROM "USER_TABLES" WHERE "TABLE_NAME" = 'migrations'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
typeorm migration:run
Runs all pending migrations.
Options:
-h, --help Show help [boolean]
--connection, -c Name of the connection on which run a query.
[default: "default"]
--transaction, -t Indicates if transaction should be used or not for
migration run. Enabled by default. [default: "default"]
--config, -f Name of the file with connection configuration.
[default: "ormconfig"]
-v, --version Show version number [boolean]
[Error: ORA-24422: error occurred while trying to destroy the Session Pool] {
errorNum: 24422,
offset: 0
}
我试着运行typeorm query“select*from\“migrations\”order by\“id\”desc;“
中列出的最后一个查询,但后来出现了以下错误:
bash-4.4$ typeorm query "select * from \"migrations\" \"migrations\" ordery by \"id\" desc;"
Running query: select * from "migrations" "migrations" ordery by "id" desc;
Error during query execution:
QueryFailedError: ORA-00933: SQL command not properly ended
at new QueryFailedError (/opt/app-root/src/.npm-global/lib/node_modules/typeorm/error/QueryFailedError.js:11:28)
at handler (/opt/app-root/src/.npm-global/lib/node_modules/typeorm/driver/oracle/OracleQueryRunner.js:175:45)
at Connection.custExecuteCb (/opt/app-root/src/bridge-server/node_modules/oracledb/lib/connection.js:103:7) {
message: 'ORA-00933: SQL command not properly ended',
errorNum: 933,
offset: 40,
name: 'QueryFailedError',
query: 'select * from "migrations" "migrations" ordery by "id" desc;',
parameters: []
}
我认为问题在于TypeORM使用表名别名的方式。如果删除上面的第二个\“migrations\”
,查询就可以正常工作
有人知道我该怎么做吗?谢谢你的帮助 我的假设不正确。使用
typeorm migration:generate
创建我的迁移文件而不是手动创建文件后,问题得到了解决。当迁移类中的name属性与文件名不匹配时,似乎会出现问题,但我不能完全确定