-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
"ORA-00972: identifier is too long" on alias #26993
Comments
@Hatles this should be raised with Devart. EF Core has a facility for providers to specify their maximum identifier limit, here's how SQL Server defines 128: https://github.com/dotnet/efcore/blob/main/src/EFCore.SqlServer/Metadata/Conventions/SqlServerConventionSetBuilder.cs#L56. Devart should implement the same in their Oracle provider. |
@roji Reading the full issue here, this seems to be a case where we are not respecting the limit when uniquifying identifiers. So I don't think this is a provider issue. |
Sorry, missed that. |
After switching to the SqlServer provider and using the modelBuilder.Model.SetMaxIdentifierLength(30) in my DbContext, the result is the same, this parameter is just ignored. Result query string in sql server:
The column with 31 characters is still there ([t2].[B_PARTNER_LONG_COLUMN_30_CHARS0]); |
Renaming the column with 30 characters to a column with 128 characters raise an error during sql execution in sql server too:
|
This comment was marked as outdated.
This comment was marked as outdated.
This is definitely an issue on a generated alias with an added '0' at the end, ending up with a length of 31 characters: Here is how is declared the column in the DbContext in the exemple I linked originaly with this issue: |
Sorry I didn't see that there was alias assigned which was longer and picked up from the column name itself. |
Verify 2 scenarios - column name appearing as alias and alias being picked up from definition of nominal type |
I wanted to take a look at this as this is an "easy-fix" What I found was that indeed the current implementation doesn't know anything about the max length for aliases. One of the things I found was that the SelectExpression right now just adds a unique number at the end. My idea also was to maybe reuse the Uniquifier to make it unique, but also this I'm not sure if we want to do this or not. Basically, to be able to continue with this, I need some more directions or help to be able to fix this, in my opinion this doesn't look like an easy-fix. |
@Tom-V The max identifier length in the model is the correct value to use. This will need to be made available to the select expression through dependency injection. The Uniquifer seems like the correct service to tie this all together. Note that the |
Note: SelectExpression already as logic to give aliases and unique-fy them. Just need to pass the maxLength there to truncate accordingly. No need to use Uniquifier. |
Any update on this? I have same error on .NET 7. |
@holatom This issue is in the Backlog milestone. This means that it is not planned for the next release. We will re-assess the backlog following the this release and consider this item at that time. However, keep in mind that there are many other high priority features with which it will be competing for resources. Make sure to vote (👍) for this issue if it is important to you. |
I'm migrating a project from EF core 2.1 to version 5.0. We are using an oracle database un version 11.2.
Some requests don't work anymore. The database limits symbols to 30 characters.
I have a scenario where I request an entity, include a collection of sub entities (one 2 many) and then include 2 child entities (many 2 one). The two last entities have a column with the same name with 30 characters.
The sql request generated has a left join with an alias that long 31 characters for the second "duplicated" column. Ef core seems to add a 0 at the end to make it unique.
When executing the query it results in a "ORA-00972: identifier is too long" error.
I'm using the Devart provider. I reproduce the same behavior with the Oracle provider in a simple project.
The Oracle provider says to use the MaxIdentifierLength attribute (https://docs.oracle.com/en/database/oracle/oracle-data-access-components/19.3.2/odpnt/EFCoreIdentifier.html) but it does nothing.
I found "AddToProjection" and "GenerateUniqueAlias" methods in the SelectExpression class (namespace Microsoft.EntityFrameworkCore.Query.SqlExpressions). Those methods add a counter at the end of a column name to make it unique, but there is no control over the generated alias length.
Exemple of generated query
"B_PARTNER_LONG_COLUMN_30_CHARS0" is 31 characters long
EF Core version: 5.0 (also tested in 3.1, same problem)
Database provider: Devart.Data.Oracle.EFCore 9.14.1382 / Oracle.EntityFrameworkCore 5.21.4
Target framework: .NET 5.0 (also tested in 3.1, same problem)
Operating system: Windows 10
IDE: Rider 2021.3
I'm including my test project for Oracle database. I will try to do the same with SqlServer as i think the error will be the same with the limit of 128 characters.
TestSimple.zip
The text was updated successfully, but these errors were encountered: