From 92685752871c31f70e9e916cc3a6b013150e49df Mon Sep 17 00:00:00 2001 From: Quin Lynch Date: Mon, 29 Apr 2024 15:59:59 -0300 Subject: [PATCH] fix static member reference for variables --- .../Expressions/MemberExpressionTranslator.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs index dfc688f..77158f2 100644 --- a/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs +++ b/src/EdgeDB.Net.QueryBuilder/Translators/Expressions/MemberExpressionTranslator.cs @@ -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); @@ -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--) {