Skip to content

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

Merged
merged 2 commits into from
Nov 3, 2017

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented Nov 1, 2017

Fixes #879 and #1418

hazzik
hazzik previously approved these changes Nov 1, 2017
@@ -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;
Copy link
Member

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;
Copy link
Member

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.

/// <summary>
/// The maximal length a SQL alias can have.
/// </summary>
public virtual int MaxAliasLength => 10;
Copy link
Member

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

get { return 10; }
}
/// <summary>
/// The maximal length a SQL alias can have.
Copy link
Member

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;
Copy link
Member Author

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;
Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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 + _.

Copy link
Member Author

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.

Copy link
Member Author

@fredericDelaporte fredericDelaporte Nov 2, 2017

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.

@fredericDelaporte
Copy link
Member Author

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.

hazzik
hazzik previously approved these changes Nov 2, 2017
@fredericDelaporte
Copy link
Member Author

#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.

@hazzik
Copy link
Member

hazzik commented Nov 3, 2017

@fredericDelaporte are you going to squash or merge commits?

@fredericDelaporte
Copy link
Member Author

Merge, since it is two issues. What I have squashed was the three commits concerning 879.

@hazzik
Copy link
Member

hazzik commented Nov 3, 2017

Then you need to reverse order of the commits.

AbstractCollectionPersister and SelectFragment could add additional suffix to an alias

Fixes nhibernate#1418
@@ -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
Copy link
Member

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")

@hazzik hazzik changed the title Fix #879 - Provide a correct MaxAliasLength for various dialects Correct MaxAliasLength for various dialects Nov 3, 2017
hazzik
hazzik previously approved these changes Nov 3, 2017
@hazzik
Copy link
Member

hazzik commented Nov 3, 2017

I've changed commits order, reworded messages and fixed a typo.

@fredericDelaporte
Copy link
Member Author

Sorry, done the same right now excepted reword of commit messages...

@hazzik
Copy link
Member

hazzik commented Nov 3, 2017

@fredericDelaporte force push war is fun 😂

@fredericDelaporte
Copy link
Member Author

Just reforce your push^^.

@hazzik
Copy link
Member

hazzik commented Nov 3, 2017

Ok, done.

@hazzik hazzik merged commit 6bca2b0 into nhibernate:master Nov 3, 2017
@fredericDelaporte fredericDelaporte deleted the 879 branch November 3, 2017 11:54
@hazzik hazzik added the r: Fixed label Nov 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants