Skip to content

Commit

Permalink
fix static member reference for variables
Browse files Browse the repository at this point in the history
  • Loading branch information
Quin Lynch committed Apr 29, 2024
1 parent ccb6b1c commit 9268575
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ when jsonConstant.Type.IsAssignableTo(typeof(IJsonVariable)) ||
TranslateJsonMember(writer, jsonConstant, path, context);
break;
case ConstantExpression constant:
TranslateConstantMember(writer, constant, path, context);
TranslateMemberAccess(writer, constant, path, context);
break;
// static field/property
case MemberExpression {Expression: null}:
TranslateMemberAccess(writer, null, path, context);
break;
default:
TranslateExpression(baseExpression, context, writer);
Expand Down Expand Up @@ -106,13 +110,13 @@ private void TranslateJsonMember(QueryWriter writer, ConstantExpression expressi
);
}

private void TranslateConstantMember(QueryWriter writer, ConstantExpression constant, MemberExpression[] path,
private void TranslateMemberAccess(QueryWriter writer, ConstantExpression? instance, MemberExpression[] path,
ExpressionContext context)
{
if (!EdgeDBTypeUtils.TryGetScalarType(path[0].Type, out var edgeqlType))
throw new NotSupportedException($"The type {path[0].Type} cannot be used as a query argument");

var refHolder = constant.Value;
var refHolder = instance?.Value;

for (var i = path.Length - 1; i >= 0; i--)
{
Expand Down

0 comments on commit 9268575

Please sign in to comment.