Skip to content

Commit 1ef18c6

Browse files
fixup! Provide a correct MaxAliasLength for various dialects
1 parent 66429af commit 1ef18c6

11 files changed

+30
-23
lines changed

src/NHibernate/Dialect/Dialect.cs

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

2285+
// 18 is the smallest of all dialects we handle.
22852286
/// <summary>
2286-
/// The maximal length a SQL alias can have.
2287+
/// The maximum length a SQL alias can have.
22872288
/// </summary>
2288-
public virtual int MaxAliasLength => 10;
2289+
public virtual int MaxAliasLength => 18;
22892290

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

src/NHibernate/Dialect/IngresDialect.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ public IngresDialect()
5454
}
5555

5656
// 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.
57+
// the limit for older versions, excepted many various sites mention a 32 length limit.
58+
// https://unifaceinfo.com/docs/0906/Uniface_Library_HTML/ulibrary/INS_NAMING_RULES_8EEFC1A489331BF969D2A8AA36AF2832.html
59+
// There are traces of a ticket for increasing this in version 10: http://lists.ingres.com/pipermail/bugs/2010-May/000052.html
60+
// This dialect seems to target version below 9, since there is Ingres9Dialect deriving from it.
61+
// So sticking to 32.
5862
/// <inheritdoc />
5963
public override int MaxAliasLength => 32;
6064

src/NHibernate/Dialect/MsSql2000Dialect.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +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.
680+
// Was 30 in "earlier version", without telling to which version the document apply.
681+
// https://msdn.microsoft.com/en-us/library/ms191240.aspx#Anchor_3
681682
/// <inheritdoc />
682-
public override int MaxAliasLength => 128;
683+
public override int MaxAliasLength => 30;
683684

684685
#region Overridden informational metadata
685686

src/NHibernate/Dialect/MsSql2005Dialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ public override string AppendLockHint(LockMode lockMode, string tableName)
103103
return tableName;
104104
}
105105

106+
// SQL Server 2005 supports 128.
107+
/// <inheritdoc />
108+
public override int MaxAliasLength => 128;
109+
106110
#region Overridden informational metadata
107111

108112
/// <summary>

src/NHibernate/Dialect/MySQL5Dialect.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,10 @@ public override bool SupportsInsertSelectIdentity
6161
{
6262
get { return true; }
6363
}
64+
65+
// At least MySQL 5 is said to support 64 characters for columns, but 5.7 supports 256 for aliases.
66+
// 64 seems quite good enough, being conservative.
67+
/// <inheritdoc />
68+
public override int MaxAliasLength => 64;
6469
}
6570
}

src/NHibernate/Dialect/MySQLDialect.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -514,11 +514,6 @@ 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-
522517
#region Overridden informational metadata
523518

524519
public override bool SupportsEmptyInList => false;

src/NHibernate/Dialect/Oracle12cDialect.cs

Lines changed: 5 additions & 4 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 12c. Assume 12.2 at least.
6+
/// A dialect specifically for use with Oracle 12c.
77
/// </summary>
88
/// <remarks>
99
/// The main difference between this dialect and <see cref="Oracle12cDialect"/>
@@ -39,8 +39,9 @@ public override SqlString GetLimitString(SqlString querySqlString, SqlString off
3939
return result.ToSqlString();
4040
}
4141

42-
// 128 since 12.2. https://stackoverflow.com/a/756569/1178314
43-
/// <inheritdoc />
44-
public override int MaxAliasLength => 128;
42+
// 128 since 12.2. https://stackoverflow.com/a/756569/1178314, will
43+
// have to do a 12-2c dialect for exploiting it, or wait for 13.
44+
// / <inheritdoc />
45+
//public override int MaxAliasLength => 128;
4546
}
4647
}

src/NHibernate/Dialect/PostgreSQL81Dialect.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,5 +116,9 @@ public override bool SupportsInsertSelectIdentity
116116

117117
/// <inheritdoc />
118118
public override bool SupportsDateTimeScale => true;
119+
120+
// Said to be 63 bytes at least since v8.
121+
/// <inheritdoc />
122+
public override int MaxAliasLength => 63;
119123
}
120124
}

src/NHibernate/Dialect/PostgreSQLDialect.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,6 @@ 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-
298294
#region Overridden informational metadata
299295

300296
public override bool SupportsEmptyInList => false;

src/NHibernate/Dialect/SQLiteDialect.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public override bool SupportsForeignKeyConstraintInAlterTable
397397

398398
// Said to be unlimited. http://sqlite.1065341.n5.nabble.com/Max-limits-on-the-following-td37859.html
399399
/// <inheritdoc />
400-
public override int MaxAliasLength => 100;
400+
public override int MaxAliasLength => 128;
401401

402402
[Serializable]
403403
protected class SQLiteCastFunction : CastFunction

src/NHibernate/Dialect/SybaseASA9Dialect.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,5 @@ 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;
192188
}
193189
}

0 commit comments

Comments
 (0)