我正在将TypeORM与Oracle DB一起使用。添加迁移并运行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\" \"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\"
,则效果很好。
有人知道我应该怎么做吗?感谢您的帮助!
答案 0 :(得分:0)
我的假设不正确。使用typeorm migration:generate
创建迁移文件而不是手动创建文件后,此问题已解决。当迁移类中的name属性与文件名不匹配时,似乎出现了问题,但我不确定。