From ccb6b1c66f94d64b19d3425c8de5bb60c7b72923 Mon Sep 17 00:00:00 2001 From: Quin Lynch Date: Sat, 27 Apr 2024 19:21:41 -0300 Subject: [PATCH] fix for type check --- src/EdgeDB.Net.QueryBuilder/QueryNodes/ForNode.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/EdgeDB.Net.QueryBuilder/QueryNodes/ForNode.cs b/src/EdgeDB.Net.QueryBuilder/QueryNodes/ForNode.cs index 3a0587b6..92f2a4bb 100644 --- a/src/EdgeDB.Net.QueryBuilder/QueryNodes/ForNode.cs +++ b/src/EdgeDB.Net.QueryBuilder/QueryNodes/ForNode.cs @@ -37,7 +37,7 @@ public ForNode(NodeBuilder builder) : base(builder) private WriterProxy ParseExpression(string name, string varName, string json) { // check if we're returning a query builder - if (Context.Expression!.ReturnType == typeof(IQueryBuilder)) + if (Context.Expression!.ReturnType.IsAssignableTo(typeof(IQueryBuilder))) { // parse our json value for processing by sub nodes. var jArray = JArray.Parse(json); @@ -49,9 +49,11 @@ private WriterProxy ParseExpression(string name, string varName, string json) { _ when x.Type == typeof(QueryContext) => null!, _ when ReflectionUtils.IsSubclassOfRawGeneric(typeof(JsonCollectionVariable<>), x.Type) - => typeof(JsonCollectionVariable<>).MakeGenericType(Context.CurrentType) - .GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, new Type[] { typeof(string), typeof(string), typeof(JArray)})! - .Invoke(new object?[] { name, varName, jArray })!, + => x.Type + .GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, [ + typeof(string), typeof(string), typeof(JArray) + ])! + .Invoke([name, varName, jArray])!, _ => throw new ArgumentException($"Cannot use {x.Type} as a parameter to a 'FOR' expression") }; }).ToArray();