Skip to content

Commit 18e44ed

Browse files
committed
#66: Bugfix. In IsSelfReferencing check the length before do string manipulations.
1 parent 7d1ddd2 commit 18e44ed

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

SQLite.CodeFirst/Internal/Utility/SqliteAssociationType.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ public SqliteAssociationType(AssociationType associationType, EntityContainer co
3636

3737
private static bool IsSelfReferencing(AssociationType associationType)
3838
{
39-
return associationType.Constraint.ToRole.Name.Remove(associationType.Constraint.ToRole.Name.Length - SelfReferencingPostfix.Length, SelfReferencingPostfix.Length) == associationType.Constraint.FromRole.Name;
39+
string to = associationType.Constraint.ToRole.Name;
40+
string from = associationType.Constraint.FromRole.Name;
41+
42+
if (to.Length <= SelfReferencingPostfix.Length)
43+
{
44+
return false;
45+
}
46+
47+
return to.Remove(to.Length - SelfReferencingPostfix.Length, SelfReferencingPostfix.Length) == from;
4048
}
4149

4250
public string ToRoleEntitySetName { get; set; }

0 commit comments

Comments
 (0)