Skip to content

Commit

Permalink
Fix bug: unqualified type name is treated as type-cast #680
Browse files Browse the repository at this point in the history
  • Loading branch information
Lingxi-Li committed Aug 24, 2016
1 parent 6daa551 commit 64ef70d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -965,7 +965,8 @@ private void CreateNextSegment(string text)
}

// Type cast
if (this.TryCreateTypeNameSegment(previous, identifier, parenthesisExpression))
if (text.IndexOf('.') >= 0 && // type-cast should use qualified type names
this.TryCreateTypeNameSegment(previous, identifier, parenthesisExpression))
{
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,20 @@ public void TestStringAsEnumInNamedKey()
}
#endregion

[Fact]
public void NonQualifiedTypeNameShouldNotBeTreatedAsTypeCast()
{
var model = new EdmModel();
var entityType = new EdmEntityType("NS", "Entity");
entityType.AddKeys(entityType.AddStructuralProperty("IdStr", EdmPrimitiveTypeKind.String, false));
var container = new EdmEntityContainer("NS", "Container");
var set = container.AddEntitySet("Set", entityType);
model.AddElements(new IEdmSchemaElement[] { entityType, container });

var svcRoot = new Uri("http://host", UriKind.Absolute);
var parseResult = new ODataUriParser(model, svcRoot, new Uri("http://host/Set/Date", UriKind.Absolute)).ParseUri();
Assert.True(parseResult.Path.LastSegment is KeySegment);
}

[Fact]
public void CaseInsensitiveEntitySetKeyNamePositional()
Expand Down

0 comments on commit 64ef70d

Please sign in to comment.