Skip to content

Commit 66429af

Browse files
Provide a correct MaxAliasLength for various dialects
1 parent a6f97d0 commit 66429af

15 files changed

+64
-8
lines changed

src/NHibernate.sln.DotSettings

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateConstants/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="aaBb" /&gt;</s:String>
2020
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateInstanceFields/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="_" Suffix="" Style="aaBb" /&gt;</s:String>
2121
<s:String x:Key="/Default/CodeStyle/Naming/CSharpNaming/PredefinedNamingRules/=PrivateStaticReadonly/@EntryIndexedValue">&lt;Policy Inspect="True" Prefix="" Suffix="" Style="AaBb" /&gt;</s:String>
22+
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ECSharpAttributeForSingleLineMethodUpgrade/@EntryIndexedValue">True</s:Boolean>
2223
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EAddAccessorOwnerDeclarationBracesMigration/@EntryIndexedValue">True</s:Boolean>
2324
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateBlankLinesAroundFieldToBlankLinesAroundProperty/@EntryIndexedValue">True</s:Boolean>
2425
<s:Boolean x:Key="/Default/Environment/SettingsMigration/IsMigratorApplied/=JetBrains_002EReSharper_002EPsi_002ECSharp_002ECodeStyle_002ESettingsUpgrade_002EMigrateThisQualifierSettings/@EntryIndexedValue">True</s:Boolean>

src/NHibernate/Dialect/DB2Dialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ public override string ForUpdateString
272272
get { return " for read only with rs"; }
273273
}
274274

275+
// As of DB2 9.5 documentation, limit is 128 bytes which with Unicode names could mean only 32 characters.
276+
/// <inheritdoc />
277+
public override int MaxAliasLength => 32;
278+
275279
#region Overridden informational metadata
276280

277281
public override bool SupportsEmptyInList => false;

src/NHibernate/Dialect/Dialect.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2282,10 +2282,10 @@ public virtual string LowercaseFunction
22822282
get { return "lower"; }
22832283
}
22842284

2285-
public virtual int MaxAliasLength
2286-
{
2287-
get { return 10; }
2288-
}
2285+
/// <summary>
2286+
/// The maximal length a SQL alias can have.
2287+
/// </summary>
2288+
public virtual int MaxAliasLength => 10;
22892289

22902290
/// <summary>
22912291
/// The syntax used to add a column to a table. Note this is deprecated

src/NHibernate/Dialect/FirebirdDialect.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,12 @@ private void RegisterTrigonometricFunctions()
520520
RegisterFunction("tanh", new StandardSQLFunction("tanh", NHibernateUtil.Double));
521521
}
522522

523+
// As of Firebird 2.5 documentation, limit is 30/31 (not all source are concordant), with some
524+
// cases supporting more but considered as bugs and no more tolerated in v3.
525+
// It seems it may be extended to 63 for Firebird v4.
526+
/// <inheritdoc />
527+
public override int MaxAliasLength => 30;
528+
523529
#region Informational metadata
524530

525531
/// <summary>

src/NHibernate/Dialect/InformixDialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,10 @@ public override string GetAddForeignKeyConstraintString(string constraintName, s
457457

458458
return res.ToString();
459459
}
460+
461+
// Informix 7 is said on Internet to be limited to 18. (http://www.justskins.com/forums/length-of-columns-names-143294.html)
462+
/// <inheritdoc />
463+
public override int MaxAliasLength => 18;
460464
}
461465

462466
public class IfxViolatedConstraintExtracter : TemplatedViolatedConstraintNameExtracter

src/NHibernate/Dialect/InformixDialect0940.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,8 @@ public override bool SupportsLimitOffset
146146
get { return false; }
147147
}
148148

149+
// Informix 9 is said on Internet to be limited to 128. (http://www.justskins.com/forums/length-of-columns-names-143294.html)
150+
/// <inheritdoc />
151+
public override int MaxAliasLength => 128;
149152
};
150-
}
153+
}

src/NHibernate/Dialect/IngresDialect.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ public IngresDialect()
5353
DefaultProperties[Environment.ConnectionDriver] = "NHibernate.Driver.IngresDriver";
5454
}
5555

56+
// Ingres 10.2 supports 256 bytes (so worst unicode case would mean 64 characters), but I am unable to find
57+
// the limit for older versions, excepted many various sites mention a 32 length limit. Being conservative.
58+
/// <inheritdoc />
59+
public override int MaxAliasLength => 32;
60+
5661
#region Overridden informational metadata
5762

5863
public override bool SupportsEmptyInList => false;

src/NHibernate/Dialect/MsSql2000Dialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,10 @@ public override bool SupportsSqlBatches
677677
get { return true; }
678678
}
679679

680+
// SQL Server 2005 supports 128, unable to find the information about SQL Server 2000.
681+
/// <inheritdoc />
682+
public override int MaxAliasLength => 128;
683+
680684
#region Overridden informational metadata
681685

682686
public override bool SupportsEmptyInList => false;

src/NHibernate/Dialect/MsSqlCeDialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ public override long TimestampResolutionInTicks
344344
}
345345
}
346346

347+
// SQL Server 3.5 supports 128.
348+
/// <inheritdoc />
349+
public override int MaxAliasLength => 128;
350+
347351
#region Informational metadata
348352

349353
/// <summary>

src/NHibernate/Dialect/MySQLDialect.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,11 @@ public override long TimestampResolutionInTicks
514514
/// </remarks>
515515
public override bool SupportsConcurrentWritingConnectionsInSameTransaction => false;
516516

517+
// At least MySQL 5 is said to support 64 characters for columns, but 5.7 supports 256 for aliases.
518+
// Unable to find the information about previous version, being conservative.
519+
/// <inheritdoc />
520+
public override int MaxAliasLength => 64;
521+
517522
#region Overridden informational metadata
518523

519524
public override bool SupportsEmptyInList => false;

src/NHibernate/Dialect/Oracle12cDialect.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace NHibernate.Dialect
44
{
55
/// <summary>
6-
/// A dialect specifically for use with Oracle 10g.
6+
/// A dialect specifically for use with Oracle 12c. Assume 12.2 at least.
77
/// </summary>
88
/// <remarks>
99
/// The main difference between this dialect and <see cref="Oracle12cDialect"/>
@@ -38,5 +38,9 @@ public override SqlString GetLimitString(SqlString querySqlString, SqlString off
3838

3939
return result.ToSqlString();
4040
}
41+
42+
// 128 since 12.2. https://stackoverflow.com/a/756569/1178314
43+
/// <inheritdoc />
44+
public override int MaxAliasLength => 128;
4145
}
42-
}
46+
}

src/NHibernate/Dialect/Oracle8iDialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,10 @@ public override long TimestampResolutionInTicks
533533
}
534534
}
535535

536+
// 30 before 12.1. https://stackoverflow.com/a/756569/1178314
537+
/// <inheritdoc />
538+
public override int MaxAliasLength => 30;
539+
536540
#region Overridden informational metadata
537541

538542
public override bool SupportsEmptyInList

src/NHibernate/Dialect/PostgreSQLDialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,10 @@ public override string CurrentTimestampSelectString
291291
get { return "SELECT CURRENT_TIMESTAMP"; }
292292
}
293293

294+
// Said to be 63 bytes at least since v8.
295+
/// <inheritdoc />
296+
public override int MaxAliasLength => 63;
297+
294298
#region Overridden informational metadata
295299

296300
public override bool SupportsEmptyInList => false;

src/NHibernate/Dialect/SQLiteDialect.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,10 @@ public override bool SupportsForeignKeyConstraintInAlterTable
395395
/// </remarks>
396396
public override bool SupportsConcurrentWritingConnections => false;
397397

398+
// Said to be unlimited. http://sqlite.1065341.n5.nabble.com/Max-limits-on-the-following-td37859.html
399+
/// <inheritdoc />
400+
public override int MaxAliasLength => 100;
401+
398402
[Serializable]
399403
protected class SQLiteCastFunction : CastFunction
400404
{
@@ -407,4 +411,4 @@ protected override bool CastingIsRequired(string sqlType)
407411
}
408412
}
409413
}
410-
}
414+
}

src/NHibernate/Dialect/SybaseASA9Dialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,5 +185,9 @@ private static int GetAfterSelectInsertPoint(SqlString sql)
185185
}
186186
return 0;
187187
}
188+
189+
// Not found documentation for this version, using the lowest from similar products.
190+
/// <inheritdoc />
191+
public override int MaxAliasLength => 30;
188192
}
189193
}

0 commit comments

Comments
 (0)