**What** There is actually an issue with using the `fields` query params with the way the repositories are using our custom query strategy. This pr aims to fix this issue by reworking the strategy. What we had to do was to rework the way the selects are built for each subquery in order to follow the aliasing convention and to be taken into consideration. Alongside these changes, the join used to always select everything, this needed to be changed so that if there are any selects provided for a join, the join should not select everything and let the query select the fields that are requested. Another notable change is that all the repositories are now using the repository util in order to centralize the customization and to have a single place to update when this kind of issue arises. This means that the eager relations when using the query builder are not necessarily taken into account. For that reason, I have removed the `shipping_option` eager option in favor of explicitly asking for the relations like we started to do it in some places. FIXES CORE-1413
57 lines
1.5 KiB
JavaScript
57 lines
1.5 KiB
JavaScript
const path = require("path")
|
|
|
|
const setupServer = require("../../../helpers/setup-server")
|
|
const { initDb, useDb } = require("../../../helpers/use-db")
|
|
|
|
jest.setTimeout(30000)
|
|
|
|
describe("Database options", () => {
|
|
let medusaProcess
|
|
let dbConnection
|
|
|
|
beforeAll(async () => {
|
|
const cwd = path.resolve(path.join(__dirname, "..", ".."))
|
|
dbConnection = await initDb({
|
|
cwd,
|
|
database_extra: { idle_in_transaction_session_timeout: 1000 },
|
|
})
|
|
medusaProcess = await setupServer({ cwd })
|
|
})
|
|
|
|
afterAll(async () => {
|
|
const db = useDb()
|
|
await db.shutdown()
|
|
medusaProcess.kill()
|
|
})
|
|
|
|
describe("idle_in_transaction_session_timeout", () => {
|
|
it("Resolves successfully", async () => {
|
|
expect.assertions(1)
|
|
|
|
let queryRunner
|
|
|
|
try {
|
|
queryRunner = dbConnection.createQueryRunner()
|
|
await queryRunner.connect()
|
|
|
|
await queryRunner.startTransaction()
|
|
|
|
await queryRunner.query(`select * from product`)
|
|
|
|
// Idle time is 1000 ms so this should timeout
|
|
await new Promise((resolve) =>
|
|
setTimeout(() => resolve(undefined), 2000)
|
|
)
|
|
|
|
// This query should fail with a QueryRunnerAlreadyReleasedError
|
|
await queryRunner.commitTransaction()
|
|
} catch (error) {
|
|
// Query runner will be released in case idle_in_transaction_session_timeout kicks in
|
|
expect(error?.type || error.name).toEqual(
|
|
"QueryRunnerAlreadyReleasedError"
|
|
)
|
|
}
|
|
})
|
|
})
|
|
})
|