Mapping: Improve applying guessed types on dynamic templates, closes #1446.

This commit is contained in:
Shay Banon 2011-11-09 09:02:20 +02:00
parent 75f522adaa
commit c5ebe6e86f
2 changed files with 8 additions and 4 deletions

View File

@ -603,7 +603,7 @@ public class ObjectMapper implements Mapper, AllFieldMapper.IncludeInAll {
// we need to do it here so we can handle things like attachment templates, where calling
// text (to see if its a date) causes the binary value to be cleared
if (!resolved) {
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string");
Mapper.Builder builder = context.root().findTemplateBuilder(context, currentFieldName, "string", null);
if (builder != null) {
mapper = builder.build(builderContext);
resolved = true;

View File

@ -202,7 +202,11 @@ public class RootObjectMapper extends ObjectMapper {
}
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType) {
DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, dynamicType);
return findTemplateBuilder(context, name, dynamicType, dynamicType);
}
public Mapper.Builder findTemplateBuilder(ParseContext context, String name, String dynamicType, String matchType) {
DynamicTemplate dynamicTemplate = findTemplate(context.path(), name, matchType);
if (dynamicTemplate == null) {
return null;
}
@ -215,9 +219,9 @@ public class RootObjectMapper extends ObjectMapper {
return typeParser.parse(name, dynamicTemplate.mappingForName(name, dynamicType), parserContext);
}
public DynamicTemplate findTemplate(ContentPath path, String name, String dynamicType) {
public DynamicTemplate findTemplate(ContentPath path, String name, String matchType) {
for (DynamicTemplate dynamicTemplate : dynamicTemplates) {
if (dynamicTemplate.match(path, name, dynamicType)) {
if (dynamicTemplate.match(path, name, matchType)) {
return dynamicTemplate;
}
}