Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appear ERR: "identifier is too long", with Oracle #693

Closed
destLonY opened this issue Jul 21, 2017 · 8 comments
Closed

Appear ERR: "identifier is too long", with Oracle #693

destLonY opened this issue Jul 21, 2017 · 8 comments

Comments

@destLonY
Copy link

when i use orm to connect oracle database, it's OK.
but when i use "connection.manager.find(Photo)" this function, oracle throw an ERR : "identifier is too long"!
i get a result afer i seek this problem all afternoon, the result is oracle is not allow the tablename'length and the cloumname'length overlimit the oracle‘s restraint, which is 30!
my photo'name is "t_tds_emer_event", and my colum'name is like "emer_event_id","emer_event_type", so i console the sql is "SELECT "t_tds_emer_event", "emer_event_type" AS "t_tds_emer_event_emer_event_type"...", t_tds_emer_event_emer_event_type causes this error!

@pleerock
Copy link
Member

this is a known and very very annoying issue with oracle. I dind't find a good solution for this problem, for now I suggest to shorten column and alias names

@AlexMesser
Copy link
Collaborator

fixed and released in typeorm@0.2.0-alpha.23. You can try it via npm i typeorm@next.

@JaffParker
Copy link

JaffParker commented Jan 16, 2019

I have installed TypeORM 0.2.11 and I still have this error. Here's the generated query:

SELECT "StudyRandomizationCriteria"."id" AS "StudyRandomizationCriteria_id",
       "StudyRandomizationCriteria"."studyId" AS "StudyRandomizationCriteria_stId", 
       "StudyRandomizationCriteria"."variableId" AS "StudyRandomizationCriteria_vaId", 
       "StudyRandomizationCriteria"."value" AS "StudyRandomizationCriteria_va", 
       "StudyRandomizationCriteria"."stratum" AS "StudyRandomizationCriteria_st"
   FROM "studyRandomizationCriteria" "StudyRandomizationCriteria"
   WHERE "StudyRandomizationCriteria"."studyId" = :where_0_0_0 -- PARAMETERS: [2]

UPD: I noticed that TypeORM does attempt to shorten the identifiers, but after testing the query directly in Oracle, I found that identifiers StudyRandomizationCriteria_stId and StudyRandomizationCriteria_vaId have just one extra character in them... It looks like this is a bug.

@derSoerrn95
Copy link

I also run into this issue. Is it possible to add an alias option for EntityOptions or better an alias option for RelationOptions

@havsar
Copy link

havsar commented Sep 20, 2019

This issue is still occurring in typeorm@latest

@PQMISSCMP
Copy link

arreglado y lanzado en typeorm@0.2.0-alpha.23. Puedes probarlo a través de npm i typeorm@next.

Does that beta version correct only that problem? Does not affect the overall stability of the library?

@wfpena
Copy link
Contributor

wfpena commented Jul 7, 2020

In case it helps anyone and for future reference.

I was having this same problem with oracle while doing an update using typeorm@0.2.25. The update was done like so:

const repo = getRepository(Client);
const result = await repo.update(
  { id: client.id },
  updatedClient
);

this threw the exception: ORA-00972: Identifier is too long

By logging the resulting query/DML I realised the parameters names where based on the databaseName property for the OracleDriver.

In the files OracleDriver.ts (more precisely in the method createParameter()) and UpdateQueryBuilder.ts (in the method createUpdateExpression) you can see the parameter name is based on column.databaseName for Oracle.

My (hopefully temporary) solution:

Was to override the createParameter method to use a different naming strategy for the parameters like so:

const connection = await createConnection({...});
connection.driver.createParameter = (_parameterName: string, index: number): string => {
  return ":" + (index + 1);
}

It worked for now but I expect to come up with a different, more elegant and less error prone, solution in the future.

@christian-forgacs
Copy link
Contributor

I can confirm this issue is still open.

For my test written for pull request #8959, the entity ZipCountry with combined identifier code and countryCode this messages thrown in the oracle test.

Solution was, that I shorten the entity name. #693 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants