Skip to content

Commit

Permalink
Add support for $expand containing *
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent He committed Jan 15, 2016
1 parent 70f8a36 commit f80c86e
Show file tree
Hide file tree
Showing 12 changed files with 561 additions and 51 deletions.
6 changes: 6 additions & 0 deletions src/Microsoft.OData.Core/Microsoft.OData.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,10 @@ internal sealed class TextRes {
internal const string Nodes_EntityCollectionFunctionCallNode_ItemTypeMustBeAnEntity = "Nodes_EntityCollectionFunctionCallNode_ItemTypeMustBeAnEntity";
internal const string Nodes_SingleValueFunctionCallNode_ItemTypeMustBePrimitiveOrComplexOrEnum = "Nodes_SingleValueFunctionCallNode_ItemTypeMustBePrimitiveOrComplexOrEnum";
internal const string ExpandTreeNormalizer_NonPathInPropertyChain = "ExpandTreeNormalizer_NonPathInPropertyChain";
internal const string UriExpandParser_TermIsNotValidForStar = "UriExpandParser_TermIsNotValidForStar";
internal const string UriExpandParser_TermIsNotValidForStarRef = "UriExpandParser_TermIsNotValidForStarRef";
internal const string UriExpandParser_ParentEntityIsNull = "UriExpandParser_ParentEntityIsNull";
internal const string UriExpandParser_TermWithMultipleStarNotAllowed = "UriExpandParser_TermWithMultipleStarNotAllowed";
internal const string UriSelectParser_TermIsNotValid = "UriSelectParser_TermIsNotValid";
internal const string UriSelectParser_InvalidTopOption = "UriSelectParser_InvalidTopOption";
internal const string UriSelectParser_InvalidSkipOption = "UriSelectParser_InvalidSkipOption";
Expand Down Expand Up @@ -824,6 +828,8 @@ internal sealed class TextRes {
internal const string ExceptionUtils_CheckIntegerPositive = "ExceptionUtils_CheckIntegerPositive";
internal const string ExceptionUtils_CheckLongPositive = "ExceptionUtils_CheckLongPositive";
internal const string ExceptionUtils_ArgumentStringNullOrEmpty = "ExceptionUtils_ArgumentStringNullOrEmpty";
internal const string ExpressionToken_OnlyRefAllowWithStarInExpand = "ExpressionToken_OnlyRefAllowWithStarInExpand";
internal const string ExpressionToken_NoPropAllowedAfterRef = "ExpressionToken_NoPropAllowedAfterRef";
internal const string ExpressionToken_IdentifierExpected = "ExpressionToken_IdentifierExpected";
internal const string ExpressionLexer_UnterminatedStringLiteral = "ExpressionLexer_UnterminatedStringLiteral";
internal const string ExpressionLexer_InvalidCharacter = "ExpressionLexer_InvalidCharacter";
Expand Down
6 changes: 6 additions & 0 deletions src/Microsoft.OData.Core/Microsoft.OData.Core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -831,6 +831,10 @@ Nodes_SingleValueFunctionCallNode_ItemTypeMustBePrimitiveOrComplexOrEnum=An inst

ExpandTreeNormalizer_NonPathInPropertyChain=Found a segment that isn't a path while parsing the path within a select or expand query option.

UriExpandParser_TermIsNotValidForStar=Term '{0}' is not valid in a $expand expression, as only $level option is allowed when the expanded navigation property is star.
UriExpandParser_TermIsNotValidForStarRef=Term '{0}' is not valid in a $expand expression, no option is allowed when the expanded navigation property is */$ref.
UriExpandParser_ParentEntityIsNull=Cannot get parent entity type for term '{0}' to auto populate all navigation properties.
UriExpandParser_TermWithMultipleStarNotAllowed=Term '{0}' is not valid in a $expand expression as multiple stars are not allowed.
UriSelectParser_TermIsNotValid=Term '{0}' is not valid in a $select or $expand expression.
UriSelectParser_InvalidTopOption=Top option must be a non-negative integer, it is set to '{0}' instead.
UriSelectParser_InvalidSkipOption=Skip option must be a non-negative integer, it is set to '{0}' instead.
Expand Down Expand Up @@ -919,6 +923,8 @@ ExceptionUtils_CheckIntegerPositive=A positive integer value was expected, but t
ExceptionUtils_CheckLongPositive=A positive long value was expected; however, the value '{0}' is not a valid positive long value.
ExceptionUtils_ArgumentStringNullOrEmpty=Value cannot be null or empty.

ExpressionToken_OnlyRefAllowWithStarInExpand=Only $ref is allowed with star in expand option.
ExpressionToken_NoPropAllowedAfterRef=No property is allowed after $ref segment.
ExpressionToken_IdentifierExpected=An identifier was expected at position {0}.

ExpressionLexer_UnterminatedStringLiteral=There is an unterminated string literal at position {0} in '{1}'.
Expand Down
53 changes: 53 additions & 0 deletions src/Microsoft.OData.Core/Parameterized.Microsoft.OData.Core.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5252,6 +5252,38 @@ internal static string ExpandTreeNormalizer_NonPathInPropertyChain {
}
}

/// <summary>
/// A string like "Term '{0}' is not valid in a $expand expression, as only level option is allowed when expand navigation property is star."
/// </summary>
internal static string UriExpandParser_TermIsNotValidForStar(object p0)
{
return Microsoft.OData.Core.TextRes.GetString(Microsoft.OData.Core.TextRes.UriExpandParser_TermIsNotValidForStar, p0);
}

/// <summary>
/// A string like "Term '{0}' is not valid in a $expand expression, no option is allowed when expand navigation property is */$ref."
/// </summary>
internal static string UriExpandParser_TermIsNotValidForStarRef(object p0)
{
return Microsoft.OData.Core.TextRes.GetString(Microsoft.OData.Core.TextRes.UriExpandParser_TermIsNotValidForStarRef, p0);
}

/// <summary>
/// A string like "Can not get parent entity type for Term '{0}' to auto populate all navigation properties."
/// </summary>
internal static string UriExpandParser_ParentEntityIsNull(object p0)
{
return Microsoft.OData.Core.TextRes.GetString(Microsoft.OData.Core.TextRes.UriExpandParser_ParentEntityIsNull, p0);
}

/// <summary>
/// A string like "Term '{0}' is not valid in a $expand expression as multiple stars are not allowed."
/// </summary>
internal static string UriExpandParser_TermWithMultipleStarNotAllowed(object p0)
{
return Microsoft.OData.Core.TextRes.GetString(Microsoft.OData.Core.TextRes.UriExpandParser_TermWithMultipleStarNotAllowed, p0);
}

/// <summary>
/// A string like "Term '{0}' is not valid in a $select or $expand expression."
/// </summary>
Expand Down Expand Up @@ -5794,6 +5826,27 @@ internal static string ExceptionUtils_ArgumentStringNullOrEmpty {
}
}

/// <summary>
/// A string like "Only $ref is allowed with star in expand option."
/// </summary>
internal static string ExpressionToken_OnlyRefAllowWithStarInExpand
{
get {
return Microsoft.OData.Core.TextRes.GetString(Microsoft.OData.Core.TextRes.ExpressionToken_OnlyRefAllowWithStarInExpand);
}
}

/// <summary>
/// A string like "No property is allowed after $ref segment."
/// </summary>
internal static string ExpressionToken_NoPropAllowedAfterRef
{
get
{
return Microsoft.OData.Core.TextRes.GetString(Microsoft.OData.Core.TextRes.ExpressionToken_NoPropAllowedAfterRef);
}
}

/// <summary>
/// A string like "An identifier was expected at position {0}."
/// </summary>
Expand Down
4 changes: 2 additions & 2 deletions src/Microsoft.OData.Core/UriParser/ODataQueryOptionParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ private static SelectExpandClause ParseSelectAndExpandImplementation(string sele
ExpandToken expandTree;
SelectToken selectTree;

// syntactic pass
SelectExpandSyntacticParser.Parse(select, expand, configuration, out expandTree, out selectTree);
// syntactic pass , pass in the expand parent entity type name, in case expand option contains star, will get all the parent entity navigation properties (both declared and dynamical).
SelectExpandSyntacticParser.Parse(select, expand, elementType, configuration, out expandTree, out selectTree);

// semantic pass
SelectExpandSemanticBinder binder = new SelectExpandSemanticBinder();
Expand Down
Loading

0 comments on commit f80c86e

Please sign in to comment.