Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit b20e64d

Browse files
committed
Include table name in UC generated name
1 parent f1e9fbf commit b20e64d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/ServiceStack.OrmLite/OrmLiteDialectProviderBase.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1222,15 +1222,15 @@ public virtual string ToCreateTableStatement(Type tableType)
12221222
public virtual string GetUniqueConstraints(ModelDefinition modelDef)
12231223
{
12241224
var constraints = modelDef.UniqueConstraints.Map(x =>
1225-
$"CONSTRAINT {GetUniqueConstraintName(x)} UNIQUE ({x.FieldNames.Map(f => modelDef.GetQuotedName(f,this)).Join(",")})" );
1225+
$"CONSTRAINT {GetUniqueConstraintName(x, GetTableName(modelDef))} UNIQUE ({x.FieldNames.Map(f => modelDef.GetQuotedName(f,this)).Join(",")})" );
12261226

12271227
return constraints.Count > 0
12281228
? constraints.Join(",\n")
12291229
: null;
12301230
}
12311231

1232-
protected virtual string GetUniqueConstraintName(UniqueConstraintAttribute constraint) =>
1233-
constraint.Name ?? $"UC_{constraint.FieldNames.Join("_")}";
1232+
protected virtual string GetUniqueConstraintName(UniqueConstraintAttribute constraint, string tableName) =>
1233+
constraint.Name ?? $"UC_{tableName}_{constraint.FieldNames.Join("_")}";
12341234

12351235
public virtual string GetCheckConstraint(FieldDefinition fieldDef)
12361236
{

0 commit comments

Comments
 (0)