Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,20 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16.x, 18.x, 20.x] #, 22.x]
node-container: ["node:16", "node:18", "node:20"] #, "node:22"]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

container: ${{ matrix.node-container }}
services:
crdb:
image: cockroachdb/cockroach
env:
COCKROACH_ARGS: 'start-single-node --insecure --cache=1GB --store=type=mem,size=4GB'

steps:
- uses: actions/setup-node@v4
with:
node-version: ${{matrix.node-version}}
- uses: actions/checkout@v4
- run: docker compose -f .github/workflows/test/cockroachdb.docker-compose up -d
- run: npm i
- run: chown -R 1001:127 /github/home/.npm #This fix is needed for running CLI tests
- run: cp .github/workflows/test/cockroachdb.ormconfig.json ormconfig.json
- run: npm test

Expand Down
8 changes: 0 additions & 8 deletions .github/workflows/test/cockroachdb.docker-compose

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/test/cockroachdb.ormconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
"skip": false,
"name": "cockroachdb",
"type": "cockroachdb",
"host": "localhost",
"host": "crdb",
"port": 26257,
"username": "root",
"password": "",
"database": "defaultdb"
"database": "defaultdb",
"logging": false
},

{
Expand Down
8 changes: 5 additions & 3 deletions src/driver/cockroachdb/CockroachQueryRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,9 @@ export class CockroachQueryRunner
} else {
this.storeQueries = false
this.transactionDepth -= 1
await this.query("RELEASE SAVEPOINT cockroach_restart")
// This was disabled because it failed tests after update to CRDB 24.2
// https://github.com/typeorm/typeorm/pull/11190
// await this.query("RELEASE SAVEPOINT cockroach_restart")
await this.query("COMMIT")
this.queries = []
this.isTransactionActive = false
Expand Down Expand Up @@ -1019,7 +1021,7 @@ export class CockroachQueryRunner
const enumColumns = newTable.columns.filter(
(column) => column.type === "enum" || column.type === "simple-enum",
)
for (let column of enumColumns) {
for (const column of enumColumns) {
// skip renaming for user-defined enum name
if (column.enumName) continue

Expand Down Expand Up @@ -3903,7 +3905,7 @@ export class CockroachQueryRunner
table: Table,
indexOrName: TableIndex | TableUnique | string,
): Query {
let indexName =
const indexName =
InstanceChecker.isTableIndex(indexOrName) ||
InstanceChecker.isTableUnique(indexOrName)
? indexOrName.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,10 @@ describe("query builder > locking", () => {
.createQueryBuilder(Post, "post")
.leftJoin("post.author", "user")
.setLock("pessimistic_write")
.getOne(),
.getOne()
.should.be.rejectedWith(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be breaking the transaction and making RELEASE SAVEPOINT unavailable: https://www.cockroachlabs.com/docs/stable/release-savepoint#handling-errors

Because Chai does not forward the error, Promise.all will not throw either, making EntityManager.transaction think the operation was successful, so it won't roll back.

We should probably make that function fail.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"FOR UPDATE cannot be applied to the nullable side of an outer join",
),
])
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -638,11 +638,17 @@ describe("repository > find options > locking", () => {
tables: ["post"],
},
}),
entityManager.getRepository(Post).findOne({
where: { id: 1 },
relations: { author: true },
lock: { mode: "pessimistic_write" },
}),
entityManager
.getRepository(Post)
.findOne({
where: { id: 1 },
relations: { author: true },
lock: { mode: "pessimistic_write" },
})
.should.be.rejectedWith(
"FOR UPDATE cannot be applied to the nullable side of an outer join",
),
,
])
})
}
Expand Down
Loading