-
Notifications
You must be signed in to change notification settings - Fork 3
fix: prevent exceptions when listing indices and constraints asynchronously #61
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
alexmg
wants to merge
5
commits into
FalkorDB:master
Choose a base branch
from
alexmg:fix/async-index-helpers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
719a578
fix: ListIndicesAsync and ListConstraintsAsync methods throw exceptions
alexmg ce4ea65
fix: implement YIELD support in function calls
alexmg 279a325
fix: extra null check extracting YIELD args
alexmg cc138fa
test: tiny write in tests to catch any graph init issues
alexmg ad85e3a
Merge branch 'master' into fix/async-index-helpers
alexmg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -233,18 +233,9 @@ public async Task<ResultSet> ReadOnlyQueryAsync(string query, IDictionary<string | |
| /// <returns>A result set.</returns> | ||
| public ResultSet CallProcedure(string procedure, IEnumerable<string> args = null, Dictionary<string, List<string>> kwargs = null, CommandFlags flags = CommandFlags.None) | ||
| { | ||
| args = args?.Select(a => QuoteString(a)); | ||
| var queryBody = BuildQueryBodyForProcedureCall(procedure, ref args, kwargs); | ||
|
|
||
| var queryBody = new StringBuilder(); | ||
|
|
||
| queryBody.Append(args != null ? $"CALL {procedure}({string.Join(",", args)})" : $"CALL {procedure}()"); | ||
|
|
||
| if (kwargs != null && kwargs.TryGetValue("y", out var kwargsList)) | ||
| { | ||
| queryBody.Append(string.Join(",", kwargsList)); | ||
| } | ||
|
|
||
| return Query(queryBody.ToString(), flags: flags); | ||
| return Query(queryBody, flags: flags); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -255,20 +246,11 @@ public ResultSet CallProcedure(string procedure, IEnumerable<string> args = null | |
| /// <param name="kwargs">A collection of keyword arguments.</param> | ||
| /// <param name="flags">[Optional] Command flags that are to be sent to the StackExchange.Redis connection multiplexer...</param>/// | ||
| /// <returns>A result set.</returns> | ||
| public Task<ResultSet> CallProcedureAsync(string procedure, IEnumerable<string> args, Dictionary<string, List<string>> kwargs, CommandFlags flags = CommandFlags.None) | ||
| public Task<ResultSet> CallProcedureAsync(string procedure, IEnumerable<string> args = null, Dictionary<string, List<string>> kwargs = null, CommandFlags flags = CommandFlags.None) | ||
| { | ||
| args = args.Select(a => QuoteString(a)); | ||
|
|
||
| var queryBody = new StringBuilder(); | ||
|
|
||
| queryBody.Append($"CALL {procedure}({string.Join(",", args)})"); | ||
|
|
||
| if (kwargs.TryGetValue("y", out var kwargsList)) | ||
| { | ||
| queryBody.Append(string.Join(",", kwargsList)); | ||
| } | ||
| var queryBody = BuildQueryBodyForProcedureCall(procedure, ref args, kwargs); | ||
|
|
||
| return QueryAsync(queryBody.ToString(), flags: flags); | ||
| return QueryAsync(queryBody, flags: flags); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -281,18 +263,9 @@ public Task<ResultSet> CallProcedureAsync(string procedure, IEnumerable<string> | |
| /// <returns>A result set.</returns> | ||
| public ResultSet CallProcedureReadOnly(string procedure, IEnumerable<string> args = null, Dictionary<string, List<string>> kwargs = null, CommandFlags flags = CommandFlags.None) | ||
| { | ||
| args = args.Select(a => QuoteString(a)); | ||
|
|
||
| var queryBody = new StringBuilder(); | ||
|
|
||
| queryBody.Append($"CALL {procedure}({string.Join(",", args)})"); | ||
| var queryBody = BuildQueryBodyForProcedureCall(procedure, ref args, kwargs); | ||
|
|
||
| if (kwargs != null && kwargs.TryGetValue("y", out var kwargsList)) | ||
| { | ||
| queryBody.Append(string.Join(",", kwargsList)); | ||
| } | ||
|
|
||
| return ReadOnlyQuery(queryBody.ToString(), flags: flags); | ||
| return ReadOnlyQuery(queryBody, flags: flags); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -305,18 +278,25 @@ public ResultSet CallProcedureReadOnly(string procedure, IEnumerable<string> arg | |
| /// <returns>A result set.</returns> | ||
| public Task<ResultSet> CallProcedureReadOnlyAsync(string procedure, IEnumerable<string> args = null, Dictionary<string, List<string>> kwargs = null, CommandFlags flags = CommandFlags.None) | ||
| { | ||
| args = args.Select(a => QuoteString(a)); | ||
| var queryBody = BuildQueryBodyForProcedureCall(procedure, ref args, kwargs); | ||
|
|
||
| return ReadOnlyQueryAsync(queryBody, flags: flags); | ||
| } | ||
|
|
||
| private static string BuildQueryBodyForProcedureCall(string procedure, ref IEnumerable<string> args, Dictionary<string, List<string>> kwargs) | ||
| { | ||
| args = args?.Select(QuoteString); | ||
|
|
||
| var queryBody = new StringBuilder(); | ||
|
|
||
| queryBody.Append($"CALL {procedure}({string.Join(",", args)})"); | ||
| queryBody.Append(args != null ? $"CALL {procedure}({string.Join(",", args)})" : $"CALL {procedure}()"); | ||
|
Comment on lines
+288
to
+292
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guard against null items inside Line 288 calls Suggested fix internal static string BuildQueryBodyForProcedureCall(string procedure, ref IEnumerable<string> args, Dictionary<string, List<string>> kwargs)
{
- args = args?.Select(QuoteString);
+ var quotedArgs = args?
+ .Select(a => a ?? throw new System.ArgumentException("Procedure args cannot contain null values.", nameof(args)))
+ .Select(QuoteString)
+ .ToArray();
+
+ args = quotedArgs;
var queryBody = new StringBuilder();
- queryBody.Append(args != null ? $"CALL {procedure}({string.Join(",", args)})" : $"CALL {procedure}()");
+ queryBody.Append(quotedArgs != null ? $"CALL {procedure}({string.Join(",", quotedArgs)})" : $"CALL {procedure}()");🤖 Prompt for AI Agents |
||
|
|
||
| if (kwargs.TryGetValue("y", out var kwargsList)) | ||
| if (kwargs != null && kwargs.TryGetValue("y", out var kwargsList)) | ||
| { | ||
| queryBody.Append(string.Join(",", kwargsList)); | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| return ReadOnlyQueryAsync(queryBody.ToString(), flags: flags); | ||
| return queryBody.ToString(); | ||
| } | ||
|
|
||
| /// <summary> | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preserve the previous
CallProcedureAsyncoverload.This public signature now puts
flagsafter two optional parameters. Existing consumers that calledCallProcedureAsync("db.labels", CommandFlags.None, ...)will break. Keep the old overload and forward it to this implementation instead of replacing it.Compatibility overload
📝 Committable suggestion
🤖 Prompt for AI Agents
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original
CallProcedureAsyncsignature hadargsandkwargsparameters after theprocedureparameter. Both parameters were non-nullable which was inconsistent with the other call procedure overloads that assign a defaultnullvalue.Invoking the
CallProcedureAsyncmethod withnullvalues resulted in aNullReferenceExceptionbeing thrown.The cause being the
args.Select()statement on line 1 attempting to enumerate anullinstance.It was mandatory to provide non-null values for those parameters when invoking the previous signature.
The method
CallProcedureAsync("db.labels", CommandFlags.None, ...)was not a valid signature prior to the commit because of the non-nullableargsandkwargsparameters.