Permalink
Browse files

Fixing formula for ManyToOne - many-to-one should not contain column …

…definition when formula is used
  • Loading branch information...
1 parent c24de5a commit 783638b0607a92b55d98498a97ab6db43a94a869 Maciej Szczepanski committed Sep 29, 2011
@@ -162,5 +162,18 @@ public void LazyLoadResetsNotValue()
.Not.LazyLoad().Not.Nullable())
.Element("class/many-to-one/column").HasAttribute("not-null", "true");
}
+
+ [Test]
+ public void ManyToOneFormulaShouldSetFormulaAndNotRenderColumn()
+ {
+ new MappingTester<MappedObject>()
+ .ForMapping(map =>
+ {
+ map.References(x => x.Parent)
+ .Formula("foo(bar)");
+ })
+ .Element("class/many-to-one").HasAttribute("formula", "foo(bar)")
+ .Element("class/many-to-one/column").DoesntExist();
+ }
}
}
@@ -353,7 +353,7 @@ ManyToOneMapping IManyToOneMappingProvider.GetManyToOneMapping()
mapping.Set(x => x.Name, Layer.Defaults, member.Name);
mapping.Set(x => x.Class, Layer.Defaults, new TypeReference(typeof(TOther)));
- if (columns.Count == 0)
+ if (columns.Count == 0 && !mapping.IsSpecified("Formula"))
mapping.AddColumn(Layer.Defaults, CreateColumn(member.Name + "_id"));
foreach (var column in columns)

0 comments on commit 783638b

Please sign in to comment.