Skip to content
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

SubstituteParameters doesn't check if the parameter name is not inside the quotes #142

Closed
devashe opened this issue Jun 20, 2022 · 2 comments

Comments

@devashe
Copy link

devashe commented Jun 20, 2022

private string SubstituteParameters(string commandText) =>

Failing Query Example:

SELECT 'A:L'

Fails with exception:

System.InvalidOperationException : Sequence contains no matching element
   at System.Linq.ThrowHelper.ThrowNoMatchException()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source, Func`2 predicate)
   at ClickHouse.Ado.ClickHouseParameterCollection.get_Item(String parameterName)
   at ClickHouse.Ado.ClickHouseCommand.<SubstituteParameters>b__46_0(Match m)
   at System.Text.RegularExpressions.Regex.<>c.<Replace>b__84_0(ValueTuple`5& state, Match match)
   at System.Text.RegularExpressions.RegexRunner.Scan[TState](Regex regex, String text, Int32 textstart, TState& state, MatchCallback`1 callback, Boolean reuseMatchObject, TimeSpan timeout)
   at System.Text.RegularExpressions.Regex.Run[TState](String input, Int32 startat, TState& state, MatchCallback`1 callback, Boolean reuseMatchObject)
   at System.Text.RegularExpressions.Regex.Replace(MatchEvaluator evaluator, Regex regex, String input, Int32 count, Int32 startat)
   at System.Text.RegularExpressions.Regex.Replace(String input, MatchEvaluator evaluator)
   at ClickHouse.Ado.ClickHouseCommand.SubstituteParameters(String commandText)
   at ClickHouse.Ado.ClickHouseCommand.Execute(Boolean readResponse, ClickHouseConnection connection)
   at ClickHouse.Ado.ClickHouseCommand.ExecuteReader(CommandBehavior behavior)
   at ClickHouse.Ado.ClickHouseCommand.ExecuteReader()
   at ClickHouse.Ado.ClickHouseCommand.ExecuteScalar()
   at Indeepa.Infrastructure.ClickHouseClient.ClickHouseConnector.ExecuteScalar[T](String sql, DbParameter[] parameters)
@killwort
Copy link
Owner

It is the way it is designed.
If you need to include @ or : character in your query, just double it to escape.

@devashe
Copy link
Author

devashe commented Jun 20, 2022

@killwort, thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants