-
Notifications
You must be signed in to change notification settings - Fork 934
Correct MaxAliasLength for various dialects #1415
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
Conversation
@@ -395,6 +395,10 @@ public override bool SupportsForeignKeyConstraintInAlterTable | |||
/// </remarks> | |||
public override bool SupportsConcurrentWritingConnections => false; | |||
|
|||
// Said to be unlimited. http://sqlite.1065341.n5.nabble.com/Max-limits-on-the-following-td37859.html | |||
/// <inheritdoc /> | |||
public override int MaxAliasLength => 100; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it needs to be aligned with others. Say 128.
// Ingres 10.2 supports 256 bytes (so worst unicode case would mean 64 characters), but I am unable to find | ||
// the limit for older versions, excepted many various sites mention a 32 length limit. Being conservative. | ||
/// <inheritdoc /> | ||
public override int MaxAliasLength => 32; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need not specify if we’re not sure.
src/NHibernate/Dialect/Dialect.cs
Outdated
/// <summary> | ||
/// The maximal length a SQL alias can have. | ||
/// </summary> | ||
public virtual int MaxAliasLength => 10; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take the minimum here - 18
src/NHibernate/Dialect/Dialect.cs
Outdated
get { return 10; } | ||
} | ||
/// <summary> | ||
/// The maximal length a SQL alias can have. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems it shall be "The maximum".
|
||
// 128 since 12.2. https://stackoverflow.com/a/756569/1178314 | ||
/// <inheritdoc /> | ||
public override int MaxAliasLength => 128; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, our own CI is 12.1, and fails due to that, should have stayed on the safe side here.
// cases supporting more but considered as bugs and no more tolerated in v3. | ||
// It seems it may be extended to 63 for Firebird v4. | ||
/// <inheritdoc /> | ||
public override int MaxAliasLength => 30; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems we still have a bug. A test has generated the alias requestcompletionstatus3_8691_0_
for a query, that is 32 characters long.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's because the identifier has 2 "unique" parts for some reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in "Column.cs", line 173.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or not. I'm confused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am going to have a look. I am currently adjusting lengths and sources for those lengths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is from SelectFragment.cs
suffix field. Which is a "collectionSuffix" which is a table number + _
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Run one by one, the tests succeed. It seems there is some coupling between tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coupling is very likely coming from the thread static tableCounter
in Table
class. It seems it endlessly grows as we build/discard session factories configuration.
Either this field should be reset when starting to build a session factory (if it has no more usages after build) or it should be bound to the session factory configuration instead of the thread on which it was built. (Moved to #1417.)
The SelectFragment
suffix is an additional suffix which is meant (at least in the cases I have checked) to differentiate columns of the same table in case it is auto-joined. It does not detect auto-join but simply always add the suffix according to query joins count.
It then means the Column.GetAlias
should account for that potential additional suffix by not exhausting the full maximum length. At least 3 characters should be left in my opinion, for supporting more than 9 joins (up to 99) and the additional _
of the suffix. (Moved to #1418.)
If we want want to support more than 99 joins (up to 999), we should keep 4 characters left, but I am not used to have such monstrous queries with NHibernate.
Added fix for #1418. It could be put as a separated PR, but the trouble it fixes is revealed only in this current PR, and is related. I may still drop that commit and put it in another PR if you prefer. |
5b932b2
to
32fd87d
Compare
#879 commits squashed, I have pushed the Oracle build up in its queue and intend to merge after it rather than right now, even if there is no reason for the squash to introduce a failure. |
@fredericDelaporte are you going to squash or merge commits? |
Merge, since it is two issues. What I have squashed was the three commits concerning 879. |
Then you need to reverse order of the commits. |
AbstractCollectionPersister and SelectFragment could add additional suffix to an alias Fixes nhibernate#1418
src/NHibernate/Mapping/Column.cs
Outdated
@@ -115,10 +115,14 @@ public string GetQuotedName(Dialect.Dialect d) | |||
return IsQuoted ? d.QuoteForColumnName(_name) : _name; | |||
} | |||
|
|||
// Accomodate the one character suffix appended in AbstractCollectionPersister and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo should be "Accommodate" (double "m")
I've changed commits order, reworded messages and fixed a typo. |
0b20a3b
to
3b492d5
Compare
Sorry, done the same right now excepted reword of commit messages... |
@fredericDelaporte force push war is fun 😂 |
Just reforce your push^^. |
Ok, done. |
Fixes #879 and #1418