Issue Details (XML | Word | Printable)

Key: DNET-877
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Jiri Cincura
Reporter: Pavel
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
.NET Data provider

Long aliases are generated in WHERE clause

Created: 14/Apr/19 05:37 AM   Updated: 02/May/19 10:34 AM
Component/s: Entity Framework Core
Affects Version/s: 6.6.0.0
Fix Version/s: 6.7.0.0


 Description  « Hide
When access to condition column passes through several tables, for the joined tables generated a very long alias.
And I get FirebirdSql.Data.FirebirdClient.FbException: "Dynamic SQL Error Name longer than database column size"

Example
class Table1
{
    int id
    int value
    int idTable2
    [ForeignKey("idTable2")]
    Table2 table2
}
class Table2
{
    int id
    int idTable3
    [ForeignKey("idTable3")]
    Table3 table3
}
class Table3
{
    int id
    bool condition
}

When i do:
var result = Table1.where(t => t.table2.table3.condition).select(t => value)

generates query:

SELECT
   "t"." value"
FROM
    Table1 AS "t"
    LEFT JOIN Table2 AS "t.Table2" ON "t"."idTable2" = "t.Table2"."id"
    LEFT JOIN Table3 AS "t.Table2.Table3" ON "t.Table2"."IdTable3" = "t.Table2.Table3"."id"
WHERE
    "t.Table2.Table3"."condition"



 All   Comments   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kjell Rilbe added a comment - 14/Apr/19 06:56 AM
The O/R framework MDriven solves this by adding a three letter hash of the superfluous characters when a generated identifier is longer than the allowed length. I.e. when max length is 31 characters, any identifier longer than 31 characters is truncated after 28 characters and the truncated part is replaced with a three letter hash. It also makes sure all identifiers are unique (not sure how that's done).

Jiri Cincura added a comment - 15/Apr/19 06:24 AM
This is something that needs deeper investigation. The aliases are, sadly, what EFCore expects by default in the reader. It might be possible to change this, but haven't had time to look at it yet.