如何使用 Nestjs 連線到 Planetscale
P粉311423594
2023-08-28 20:10:23
<p>我使用 typeorm 創建了一個 Nest 應用程序,其中包含 mysql 中的許多表。 </p>
<p>當我嘗試將資料庫連接到planetscale時,它顯示相應的錯誤:</p>
<pre class="brush:php;toolbar:false;">[Nest] 9160 - 03/23/2023, 3:56:07AM **ERROR [ExceptionHandler] can't push predicates on concatenate**
QueryFailedError: **can't push predicates on concatenate**
at Query.onResult (/workspaces/result-gen/src/driver/mysql/MysqlQueryRunner.ts:222:33)
at Query.execute (/workspaces/result-gen/node_modules/mysql2/lib/commands/command.js:36:14)
at PoolConnection.handlePacket (/workspaces/result-gen/node_modules/mysql2/lib/connection.js:488:32)
at PacketParser.onPacket (/workspaces/result-gen/node_modules/mysql2/lib/connection.js:94:12)
at PacketParser.executeStart (/workspaces/result-gen/node_modules/mysql2/lib/packet_parser.js:75:16)
at TLSSocket.<anonymous> (/workspaces/result-gen/node_modules/mysql2/lib/connection.js:387:25)
at TLSSocket.emit (node:events:512:28)
at addChunk (node:internal/streams/readable:324:12)
at readableAddChunk (node:internal/streams/readable:297:9)
at TLSSocket.Readable.push (node:internal/streams/readable:234:10)</pre>
<p>當我嘗試將其連接到 <strong>planetscale</strong> 線上資料庫時,我有許多表格由許多行組成,它顯示了這些錯誤。 </p>
<p>請幫我處理此資料庫連接,不要有任何錯誤...</p>
根據 PlanetScale Github 儲存庫,似乎有修復此問題的方法更新。同時,我設法透過在
app.module
的TypeOrmModule
參數以及配置的 DataSource 中添加以下程式碼來解決這個問題。