Skip to content

Commit

Permalink
fix for type check
Browse files Browse the repository at this point in the history
  • Loading branch information
Quin Lynch committed Apr 27, 2024
1 parent 2df336e commit ccb6b1c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/EdgeDB.Net.QueryBuilder/QueryNodes/ForNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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();
Expand Down

0 comments on commit ccb6b1c

Please sign in to comment.