diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 73aaf1d901..c2b92499fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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 diff --git a/.github/workflows/test/cockroachdb.docker-compose b/.github/workflows/test/cockroachdb.docker-compose deleted file mode 100644 index 448ca832c3..0000000000 --- a/.github/workflows/test/cockroachdb.docker-compose +++ /dev/null @@ -1,8 +0,0 @@ -version: "3" -services: - cockroachdb: - image: "cockroachdb/cockroach:v23.1.9" - container_name: "typeorm-cockroachdb" - command: start-single-node --insecure --cache=0.75 --store=type=mem,size=0.75 - ports: - - "26257:26257" diff --git a/.github/workflows/test/cockroachdb.ormconfig.json b/.github/workflows/test/cockroachdb.ormconfig.json index e9501327a6..170374b7f2 100644 --- a/.github/workflows/test/cockroachdb.ormconfig.json +++ b/.github/workflows/test/cockroachdb.ormconfig.json @@ -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 }, { diff --git a/src/driver/cockroachdb/CockroachQueryRunner.ts b/src/driver/cockroachdb/CockroachQueryRunner.ts index f6d3d16f2d..45e3b250a9 100644 --- a/src/driver/cockroachdb/CockroachQueryRunner.ts +++ b/src/driver/cockroachdb/CockroachQueryRunner.ts @@ -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 @@ -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 @@ -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 diff --git a/test/functional/query-builder/locking/query-builder-locking.ts b/test/functional/query-builder/locking/query-builder-locking.ts index b141ff2064..84b2ae82f9 100644 --- a/test/functional/query-builder/locking/query-builder-locking.ts +++ b/test/functional/query-builder/locking/query-builder-locking.ts @@ -975,7 +975,10 @@ describe("query builder > locking", () => { .createQueryBuilder(Post, "post") .leftJoin("post.author", "user") .setLock("pessimistic_write") - .getOne(), + .getOne() + .should.be.rejectedWith( + "FOR UPDATE cannot be applied to the nullable side of an outer join", + ), ]) }) } diff --git a/test/functional/repository/find-options-locking/find-options-locking.ts b/test/functional/repository/find-options-locking/find-options-locking.ts index 020c9b2118..a554372857 100644 --- a/test/functional/repository/find-options-locking/find-options-locking.ts +++ b/test/functional/repository/find-options-locking/find-options-locking.ts @@ -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", + ), + , ]) }) }