From ccb9879b628fe0435d22a9eb82ae59d412c4ab42 Mon Sep 17 00:00:00 2001 From: Murat Gundes Date: Wed, 19 Aug 2020 15:27:18 +0200 Subject: [PATCH 1/4] fix: resolve issues ora-00972:identifier is too long Closes: #5067 --- src/driver/oracle/OracleDriver.ts | 2 +- test/github-issues/5067/issue-5067.ts | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/github-issues/5067/issue-5067.ts diff --git a/src/driver/oracle/OracleDriver.ts b/src/driver/oracle/OracleDriver.ts index 3d02f3b537..52a2bf46f9 100644 --- a/src/driver/oracle/OracleDriver.ts +++ b/src/driver/oracle/OracleDriver.ts @@ -635,7 +635,7 @@ export class OracleDriver implements Driver { * Creates an escaped parameter. */ createParameter(parameterName: string, index: number): string { - return ":" + parameterName; + return ":" + (index + 1); } /** diff --git a/test/github-issues/5067/issue-5067.ts b/test/github-issues/5067/issue-5067.ts new file mode 100644 index 0000000000..b54159900f --- /dev/null +++ b/test/github-issues/5067/issue-5067.ts @@ -0,0 +1,24 @@ +import "reflect-metadata"; +import {expect} from "chai"; +import {Connection} from "../../../src"; +import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils"; + +describe.only("github issues > #5067 ORA-00972: identifier is too long", () => { + let connections: Connection[]; + before(async () => connections = await createTestingConnections({ + entities: [__dirname + "/entity/*{.js,.ts}"] + })); + after(() => closeTestingConnections(connections)); + + it("generated parameter name returns index instead of parameter name", () => Promise.all(connections.map(async connection => { + const paramName = "output_"; + const parametersCount = 0; + const createdParameter = await connection.driver.createParameter(paramName, parametersCount); + + expect(createdParameter).to.be.not.undefined; + expect(createdParameter).to.be.not.null; + expect(createdParameter).to.be.an("String"); + expect(createdParameter).to.not.match(/(?:output_)/); + expect(await connection.driver.createParameter(paramName, 2)).to.equal(":" + 3); + }))); +}); From a3fe2eaa32a6e35d187b2dd88b6456784a8f4d25 Mon Sep 17 00:00:00 2001 From: Murat Gundes Date: Wed, 19 Aug 2020 15:46:46 +0200 Subject: [PATCH 2/4] fix: ensure that this changes applies just for Oracle Driver Closes: #5067 --- test/github-issues/5067/issue-5067.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/test/github-issues/5067/issue-5067.ts b/test/github-issues/5067/issue-5067.ts index b54159900f..5feb424bdd 100644 --- a/test/github-issues/5067/issue-5067.ts +++ b/test/github-issues/5067/issue-5067.ts @@ -2,6 +2,7 @@ import "reflect-metadata"; import {expect} from "chai"; import {Connection} from "../../../src"; import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils"; +import {OracleDriver} from "../../../src/driver/oracle/OracleDriver"; describe.only("github issues > #5067 ORA-00972: identifier is too long", () => { let connections: Connection[]; @@ -11,14 +12,17 @@ describe.only("github issues > #5067 ORA-00972: identifier is too long", () => { after(() => closeTestingConnections(connections)); it("generated parameter name returns index instead of parameter name", () => Promise.all(connections.map(async connection => { - const paramName = "output_"; - const parametersCount = 0; - const createdParameter = await connection.driver.createParameter(paramName, parametersCount); + if (connection.driver instanceof OracleDriver) + { + const paramName = "output_"; + const parametersCount = 0; + const createdParameter = await connection.driver.createParameter(paramName, parametersCount); - expect(createdParameter).to.be.not.undefined; - expect(createdParameter).to.be.not.null; - expect(createdParameter).to.be.an("String"); - expect(createdParameter).to.not.match(/(?:output_)/); - expect(await connection.driver.createParameter(paramName, 2)).to.equal(":" + 3); + expect(createdParameter).to.be.not.undefined; + expect(createdParameter).to.be.not.null; + expect(createdParameter).to.be.an("String"); + expect(createdParameter).to.not.match(/(?:output_)/); + expect(await connection.driver.createParameter(paramName, 2)).to.equal(":" + 3); + } }))); }); From 3776ea8f859302e7a16e6775b387266d48d77ebc Mon Sep 17 00:00:00 2001 From: James Ward Date: Mon, 21 Sep 2020 11:54:48 -0400 Subject: [PATCH 3/4] fix test - remove `.only` & set the `enabledDrivers` to oracle --- test/github-issues/5067/issue-5067.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/github-issues/5067/issue-5067.ts b/test/github-issues/5067/issue-5067.ts index 5feb424bdd..e6a6bb8131 100644 --- a/test/github-issues/5067/issue-5067.ts +++ b/test/github-issues/5067/issue-5067.ts @@ -4,10 +4,11 @@ import {Connection} from "../../../src"; import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils"; import {OracleDriver} from "../../../src/driver/oracle/OracleDriver"; -describe.only("github issues > #5067 ORA-00972: identifier is too long", () => { +describe("github issues > #5067 ORA-00972: identifier is too long", () => { let connections: Connection[]; before(async () => connections = await createTestingConnections({ - entities: [__dirname + "/entity/*{.js,.ts}"] + entities: [__dirname + "/entity/*{.js,.ts}"], + enabledDrivers: ["oracle"] })); after(() => closeTestingConnections(connections)); From d7c57bd4ad6f6cd1c5ffe6bb5e5b8aa1fec6a58d Mon Sep 17 00:00:00 2001 From: James Ward Date: Tue, 22 Sep 2020 02:48:30 -0400 Subject: [PATCH 4/4] simplify test case --- test/github-issues/5067/issue-5067.ts | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/test/github-issues/5067/issue-5067.ts b/test/github-issues/5067/issue-5067.ts index e6a6bb8131..3082a03894 100644 --- a/test/github-issues/5067/issue-5067.ts +++ b/test/github-issues/5067/issue-5067.ts @@ -2,28 +2,19 @@ import "reflect-metadata"; import {expect} from "chai"; import {Connection} from "../../../src"; import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils"; -import {OracleDriver} from "../../../src/driver/oracle/OracleDriver"; describe("github issues > #5067 ORA-00972: identifier is too long", () => { let connections: Connection[]; before(async () => connections = await createTestingConnections({ - entities: [__dirname + "/entity/*{.js,.ts}"], enabledDrivers: ["oracle"] })); after(() => closeTestingConnections(connections)); - it("generated parameter name returns index instead of parameter name", () => Promise.all(connections.map(async connection => { - if (connection.driver instanceof OracleDriver) - { - const paramName = "output_"; - const parametersCount = 0; - const createdParameter = await connection.driver.createParameter(paramName, parametersCount); + it("generated parameter name is within the size constraints", () => Promise.all(connections.map(async connection => { + const paramName = "output_that_is_really_long_and_must_be_truncated_in_this_driver"; + const createdParameter = await connection.driver.createParameter(paramName, 0); - expect(createdParameter).to.be.not.undefined; - expect(createdParameter).to.be.not.null; - expect(createdParameter).to.be.an("String"); - expect(createdParameter).to.not.match(/(?:output_)/); - expect(await connection.driver.createParameter(paramName, 2)).to.equal(":" + 3); - } + expect(createdParameter).to.be.an("String"); + expect(createdParameter.length).to.be.lessThan(30); }))); });