Database constraint names and hash collision
"Alun Harford" <[email protected]> Mon, 14 Jul 2008 03:12:35 -0700
| Newsgroups | gmane.comp.windows.dotnet.nhibernate.devel |
|---|---|
| Message-ID | <93BA6C2C05B6974A9F25DA49D4F046BA025F4BF2@EXVBE014-13.exch014.msoutlookonline.net> |
Hello all,
namespace NHibernate.Mapping
{
...
public class Table : IRelationalModel
{
...
public string UniqueColumnString(IEnumerable iterator, string
referencedEntityName)
{
...
return (name.GetHashCode().ToString("X") +
result.GetHashCode().ToString("X")); // Ouch!
}
}
}
We've just hit a problem on this line where we have two constraints on
the same table.
Because they're on the same table, name is the same.
And we have found a hash collision on result, due to weakness in how
result is being generated.
Adding hashes together for string hashes isn't safe.
In our case,
"BluewireTechnologies.Core.Framework.DynamicTypes2.Albatross.ITestManyA"
.GetHashCode()+"itestmanyaid".GetHashCode()
Is equal to:
"BluewireTechnologies.Core.Framework.DynamicTypes2.Albatross.ITestManyB"
.GetHashCode()+"itestmanybid".GetHashCode()
On V2 runtime.
Changing this code would cause the schemas NHibernate generates to
change :-(
How much of people's code would this break? (I don't use NHibernate in a
very conventional way, so I'm not very familiar with this)
Is it worth submitting a patch, or are we going to have to live with the
broken behaviour for backwards compatibility?
Alun Harford
-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Nhibernate-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nhibernate-development